From fdc0c4b5deee6c8de7105f10d1dd1a9107f1a654 Mon Sep 17 00:00:00 2001 From: hminaee-tc Date: Fri, 5 Jul 2024 14:47:33 -0300 Subject: [PATCH 1/3] feat/exclude-config exclude config --- .../find_and_replace_strings/main.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/opencepk_lib_python_common/find_and_replace_strings_package/find_and_replace_strings/main.py b/opencepk_lib_python_common/find_and_replace_strings_package/find_and_replace_strings/main.py index 4fcf711..f392493 100755 --- a/opencepk_lib_python_common/find_and_replace_strings_package/find_and_replace_strings/main.py +++ b/opencepk_lib_python_common/find_and_replace_strings_package/find_and_replace_strings/main.py @@ -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.") @@ -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() From 9c966ecf11f0cc11a53a3523ee768126336b2ac7 Mon Sep 17 00:00:00 2001 From: hminaee-tc Date: Fri, 5 Jul 2024 14:50:44 -0300 Subject: [PATCH 2/3] feat/exclude-config exclude config --- .../find_and_replace_strings/main.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opencepk_lib_python_common/find_and_replace_strings_package/find_and_replace_strings/main.py b/opencepk_lib_python_common/find_and_replace_strings_package/find_and_replace_strings/main.py index f392493..5e4313e 100755 --- a/opencepk_lib_python_common/find_and_replace_strings_package/find_and_replace_strings/main.py +++ b/opencepk_lib_python_common/find_and_replace_strings_package/find_and_replace_strings/main.py @@ -104,6 +104,6 @@ def main(): continue for replacement in replacements: replace_in_file(filename, replacement['search'], replacement['replacement'], args.dry_run) - + if __name__ == "__main__": main() diff --git a/pyproject.toml b/pyproject.toml index 9a80192..018fc86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ packages = { find = { where = ["."] } } [project] name = "opencepk-lib-python-common" -version = "1.1.1" +version = "1.1.2" description = "Common Python opencepk packages." readme = "README.md" license = { text = "GPLv3" } From a57c31a76c2ae6a887a2be917f8e3b4b28eed6d6 Mon Sep 17 00:00:00 2001 From: hminaee-tc Date: Fri, 5 Jul 2024 14:55:28 -0300 Subject: [PATCH 3/3] feat/exclude-config exclude config --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 018fc86..d2cc71e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ packages = { find = { where = ["."] } } [project] name = "opencepk-lib-python-common" -version = "1.1.2" +version = "1.2.0" description = "Common Python opencepk packages." readme = "README.md" license = { text = "GPLv3" }