From 938147ba657beffdb1009c1baf72e5648a25a0ab Mon Sep 17 00:00:00 2001 From: Sindre Stephansen Date: Mon, 31 Jul 2023 09:58:23 +0200 Subject: [PATCH] Minor fixes --- sync/src/main.py | 2 +- sync/src/pom.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sync/src/main.py b/sync/src/main.py index 170a5bf..19c4b1f 100644 --- a/sync/src/main.py +++ b/sync/src/main.py @@ -36,7 +36,7 @@ async def main(package_list: Path, output_dir: Path, gradle_repo: str) -> None: if not config: print('Error in configuration') - if not config.configurations: + elif not config.configurations: print('No configurations defined, nothing to do.') elif not config.mirrors: print('No mirrors defined. Add maven.mirrors in the config file.') diff --git a/sync/src/pom.py b/sync/src/pom.py index 997859d..cb00aa3 100644 --- a/sync/src/pom.py +++ b/sync/src/pom.py @@ -8,7 +8,7 @@ from xmlutils import pom_namespace as ns, find_tag_text logger = logging.getLogger(__name__) -Properties: TypeAlias = dict[str, Optional[str]] +Properties: TypeAlias = dict[str, str] class PropertyMissing(Exception): @@ -76,7 +76,10 @@ class PackagePOM: changed = False for prop, value in props.items(): - new_value = self._prop_replace(value, props, True) + try: + new_value = self._prop_replace(value, props) + except PropertyMissing: + continue if new_value != value: changed = True @@ -85,7 +88,7 @@ class PackagePOM: self.properties = props - def _prop_replace(self, text, props: Optional[Properties] = None, quiet: bool = False) -> str: + def _prop_replace(self, text: str, props: Optional[Properties] = None) -> str: def lookup_prop(match) -> str: prop = match.group(1) @@ -105,7 +108,7 @@ class PackagePOM: except KeyError: value = None - if value is None and not quiet: + if value is None: raise PropertyMissing(prop) else: logger.debug(f'{self.name}: Replacing property {prop} with {value}')