Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/exclude-config exclude config #13

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading