From 393faa8940012bf2a8f082e8f8eb3732a394c1b2 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Fri, 19 Jan 2024 14:30:22 +0100 Subject: [PATCH 1/3] Improve documentation. --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index dc2c716..736560d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,13 @@ Bi-directional version.cfg <–> requirements.txt synchronization +This program can be used to synchronize a `versions.cfg` used by +[zc.buildout](https://pypi.org/project/zc.buildout/) with a `requirements.txt` +as used by [pip](https://pypi.org/project/pip/). + +This is be helpful to keep using `zc.buildout` but get version updates via +GitHub's Dependabot. + ----- **Table of Contents** From 953581f265061a69390ebd453b3fe01ac2c15d20 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Fri, 19 Jan 2024 14:30:32 +0100 Subject: [PATCH 2/3] Fix version number. --- src/vereqsyn/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vereqsyn/__about__.py b/src/vereqsyn/__about__.py index cb689b6..a9a6f9c 100644 --- a/src/vereqsyn/__about__.py +++ b/src/vereqsyn/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2024-present Michael Howitz # # SPDX-License-Identifier: MIT -__version__ = "0.0.1" +__version__ = "0.9" From 9abe7f7552d77b1607e398cb2441954090bc10db Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Fri, 19 Jan 2024 14:30:50 +0100 Subject: [PATCH 3/3] Rename version to versions. --- src/vereqsyn/__init__.py | 2 +- src/vereqsyn/__main__.py | 10 +++++----- tests/test_vereqsyn.py | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/vereqsyn/__init__.py b/src/vereqsyn/__init__.py index 2723fcd..4b45537 100644 --- a/src/vereqsyn/__init__.py +++ b/src/vereqsyn/__init__.py @@ -28,7 +28,7 @@ def _cleanup(self): @dataclass -class VersionCfgRequirementsTxtSync: +class VersionsCfgRequirementsTxtSync: """Keep a versions.cfg in sync with a requirements.txt file.""" requirements_txt: str | None = None diff --git a/src/vereqsyn/__main__.py b/src/vereqsyn/__main__.py index bcd5df8..b871324 100644 --- a/src/vereqsyn/__main__.py +++ b/src/vereqsyn/__main__.py @@ -6,14 +6,14 @@ def main(argv=None): parser = argparse.ArgumentParser( "vereqsyn", - "{prog} ", - "Bi-directional version.cfg <-> requirements.txt synchronization", + "%(prog)s ", + "Bi-directional versions.cfg <-> requirements.txt synchronization", ) - parser.add_argument("version_cfg", action="store") - parser.add_argument("requirements_txt", action="store") + parser.add_argument("versions_cfg", action="store", help="path to versions.cfg") + parser.add_argument("requirements_txt", action="store", help="path to requirements.txt") args = parser.parse_args(argv) - command = vereqsyn.VersionCfgRequirementsTxtSync(args.requirements_txt, args.version_cfg) + command = vereqsyn.VersionsCfgRequirementsTxtSync(args.requirements_txt, args.versions_cfg) command.update() diff --git a/tests/test_vereqsyn.py b/tests/test_vereqsyn.py index be70077..9ddc588 100644 --- a/tests/test_vereqsyn.py +++ b/tests/test_vereqsyn.py @@ -2,7 +2,7 @@ import pytest -from vereqsyn import ConfigFile, VersionCfgRequirementsTxtSync +from vereqsyn import ConfigFile, VersionsCfgRequirementsTxtSync from .testing import tmp_copy @@ -11,7 +11,7 @@ def test_VersionCfg_RequirementsTxt_Sync___sync__1(fixtures, tmp_path): """It syncs newer versions in both directions.""" r3 = tmp_copy(tmp_path, fixtures / "r3.txt") v3 = tmp_copy(tmp_path, fixtures / "v3.cfg") - component = VersionCfgRequirementsTxtSync(r3, v3) + component = VersionsCfgRequirementsTxtSync(r3, v3) assert not component.in_sync() component._sync() # noqa: SLF001 Private member accessed assert component.in_sync() @@ -19,7 +19,7 @@ def test_VersionCfg_RequirementsTxt_Sync___sync__1(fixtures, tmp_path): def test_VersionCfg_RequirementsTxt_Sync___sync__2(fixtures): """It raises an exception if the package names are out of order.""" - component = VersionCfgRequirementsTxtSync(fixtures / "r1.txt", fixtures / "v2.cfg") + component = VersionsCfgRequirementsTxtSync(fixtures / "r1.txt", fixtures / "v2.cfg") with pytest.raises(ReferenceError) as err: component._sync() # noqa: SLF001 Private member accessed assert str(err.value).startswith("Package entries out of order: Faker != FactoryBoy. Please recreate") @@ -29,7 +29,7 @@ def test_VersionCfg_RequirementsTxt_Sync___recreate__1(fixtures, tmp_path): """It recreates requirements.txt from versions.cfg.""" r1 = tmp_copy(tmp_path, fixtures / "r1.txt") v2 = tmp_copy(tmp_path, fixtures / "v2.cfg") - component = VersionCfgRequirementsTxtSync(r1, v2) + component = VersionsCfgRequirementsTxtSync(r1, v2) assert not component.in_sync() component._recreate() # noqa: SLF001 Private member accessed assert component.in_sync() @@ -37,7 +37,7 @@ def test_VersionCfg_RequirementsTxt_Sync___recreate__1(fixtures, tmp_path): def test_VersionCfg_RequirementsTxt_Sync__in_sync__1(fixtures): """It returns `True` if config files are in sync.""" - component = VersionCfgRequirementsTxtSync(requirements_txt=fixtures / "r1.txt", version_cfg=fixtures / "v1.cfg") + component = VersionsCfgRequirementsTxtSync(requirements_txt=fixtures / "r1.txt", version_cfg=fixtures / "v1.cfg") assert component.in_sync() @@ -52,7 +52,7 @@ def test_VersionCfg_RequirementsTxt_Sync__in_sync__1(fixtures): ) def test_VersionCfg_RequirementsTxt_Sync__in_sync__2(fixtures, r_name, v_name): """It returns `False` if config files are out of sync.""" - component = VersionCfgRequirementsTxtSync(requirements_txt=fixtures / r_name, version_cfg=fixtures / v_name) + component = VersionsCfgRequirementsTxtSync(requirements_txt=fixtures / r_name, version_cfg=fixtures / v_name) assert not component.in_sync() @@ -60,7 +60,7 @@ def test_VersionCfg_RequirementsTxt_Sync__update__1(fixtures, tmp_path): """It updates out of sync files.""" r3 = tmp_copy(tmp_path, fixtures / "r3.txt") v3 = tmp_copy(tmp_path, fixtures / "v3.cfg") - component = VersionCfgRequirementsTxtSync(requirements_txt=r3, version_cfg=v3) + component = VersionsCfgRequirementsTxtSync(requirements_txt=r3, version_cfg=v3) assert not component.in_sync() component.update() assert component.in_sync() @@ -70,7 +70,7 @@ def test_VersionCfg_RequirementsTxt_Sync__update__2(fixtures, tmp_path): """It recreates requirements.txt if packages are out of order.""" r1 = tmp_copy(tmp_path, fixtures / "r1.txt") v2 = tmp_copy(tmp_path, fixtures / "v2.cfg") - component = VersionCfgRequirementsTxtSync(requirements_txt=r1, version_cfg=v2) + component = VersionsCfgRequirementsTxtSync(requirements_txt=r1, version_cfg=v2) assert not component.in_sync() component.update() assert component.in_sync()