From e919a2725c519f08d0576c355cced64cda68870d Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 28 Sep 2021 00:44:05 -0400 Subject: [PATCH] [ADD] poetry_update.py: dry option to execute without result Signed-off-by: Mathieu Benoit --- script/poetry_update.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/script/poetry_update.py b/script/poetry_update.py index 5352e36..97b2c0f 100755 --- a/script/poetry_update.py +++ b/script/poetry_update.py @@ -54,6 +54,11 @@ def get_config(): action="store_true", help="More information in execution, show stats.", ) + parser.add_argument( + "--dry", + action="store_true", + help="Don't apply change, only show warning.", + ) args = parser.parse_args() return args @@ -349,15 +354,17 @@ def main(): # repo = Repo(root_path) # lst_repo = get_all_repo() config = get_config() - pyproject_toml_filename = f"{config.dir}pyproject.toml" - delete_dependency_poetry(pyproject_toml_filename) + if not config.dry: + pyproject_toml_filename = f"{config.dir}pyproject.toml" + delete_dependency_poetry(pyproject_toml_filename) combine_requirements(config) - if config.force and os.path.isfile("./poetry.lock"): - os.remove("./poetry.lock") - status = call_poetry_add_build_dependency() - if status: - sorted_dependency_poetry(pyproject_toml_filename) + if not config.dry: + if config.force and os.path.isfile("./poetry.lock"): + os.remove("./poetry.lock") + status = call_poetry_add_build_dependency() + if status: + sorted_dependency_poetry(pyproject_toml_filename) if __name__ == "__main__":