[arch.version] refactoring: String formatting method

This commit is contained in:
Vinicius Moreira
2022-04-04 16:13:10 -03:00
parent 9e2184a0e9
commit 8a935a924a
2 changed files with 9 additions and 4 deletions

View File

@@ -6,10 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.10.2] ## [0.10.2]
### Improvements
- General
- code refactoring
### Fixes ### Fixes
- Debian - Debian
- info: crashing when the package size has unexpected symbols [#251](https://github.com/vinifmor/bauh/issues/251) - info: crashing when the package size has unexpected symbols [#251](https://github.com/vinifmor/bauh/issues/251)
## [0.10.1] 2022-03-31 ## [0.10.1] 2022-03-31
### Features ### Features

View File

@@ -10,10 +10,10 @@ def normalize_version(version: str) -> LegacyVersion:
final_version = version.strip() final_version = version.strip()
if not RE_VERSION_WITH_EPOCH.match(final_version): if not RE_VERSION_WITH_EPOCH.match(final_version):
final_version = '0:{}'.format(final_version) final_version = f'0:{final_version}'
if not RE_VERSION_WITH_RELEASE.match(final_version): if not RE_VERSION_WITH_RELEASE.match(final_version):
final_version = '{}-1'.format(final_version) final_version = f'{final_version}-1'
return LegacyVersion(final_version) return LegacyVersion(final_version)
@@ -25,7 +25,7 @@ def match_required_version(current_version: str, operator: str, required_version
current_has_epoch = len(current_no_epoch) > 1 current_has_epoch = len(current_no_epoch) > 1
if required_has_epoch and not current_has_epoch: if required_has_epoch and not current_has_epoch:
final_current = '0:{}'.format(final_current) final_current = f'0:{final_current}'
elif current_has_epoch and not required_has_epoch: elif current_has_epoch and not required_has_epoch:
final_current = current_no_epoch[1] final_current = current_no_epoch[1]
@@ -33,7 +33,7 @@ def match_required_version(current_version: str, operator: str, required_version
current_has_release = len(current_no_release) > 1 current_has_release = len(current_no_release) > 1
if required_has_release and not current_has_release: if required_has_release and not current_has_release:
final_current = '{}-1'.format(final_current) final_current = f'{final_current}-1'
elif current_has_release and not required_has_release: elif current_has_release and not required_has_release:
final_current = current_no_release[1] final_current = current_no_release[1]