Skip to content

Commit

Permalink
Feat/exclude config: exclude config json passed from replacing functi…
Browse files Browse the repository at this point in the history
…onality (#14)

* feat/exclude-config exclude config
  • Loading branch information
hminaee-tc authored Jul 5, 2024
1 parent ebe3749 commit 2437d0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,20 @@ def main():
level = logging.DEBUG
logging.basicConfig(level=level)

config_path = os.path.abspath(args.config)

if args.direct_mode:
logging.info("Running in direct mode")
for filename in args.files:
file_path = os.path.abspath(filename)
if file_path == config_path:
logging.info(f"Skipping config file: {filename}")
continue
replace_in_file(filename, args.find, args.replacement, args.dry_run)
else:
logging.info("Running in default config file mode")
try:
with open(os.path.join(os.getcwd(), args.config), 'r') as f:
with open(config_path, 'r') as f:
replacements = json.load(f)
except FileNotFoundError:
logging.error(f"Error: {args.config} file not found.")
Expand All @@ -92,9 +98,12 @@ def main():
sys.exit(1)

for filename in args.files:
file_path = os.path.abspath(filename)
if file_path == config_path:
logging.info(f"Skipping config file: {filename}")
continue
for replacement in replacements:
replace_in_file(filename, replacement['search'], replacement['replacement'], args.dry_run)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages = { find = { where = ["."] } }

[project]
name = "opencepk-lib-python-common"
version = "1.1.1"
version = "1.2.0"
description = "Common Python opencepk packages."
readme = "README.md"
license = { text = "GPLv3" }
Expand Down

0 comments on commit 2437d0a

Please sign in to comment.