harbor_cli.utils.utils
Utility functions that can't be neatly categorized, or are so niche that they don't need their own module.
Attributes
MutableMappingType = TypeVar('MutableMappingType', bound=MutableMapping[Any, Any])
module-attribute
Classes
PackageVersion
Bases: NamedTuple
Source code in harbor_cli/utils/utils.py
Attributes
package: str
instance-attribute
min_version: Optional[str] = None
class-attribute
instance-attribute
max_version: Optional[str] = None
class-attribute
instance-attribute
not_version: Optional[str] = None
class-attribute
instance-attribute
Functions
replace_none(d: Optional[MutableMappingType], replacement: Any = '') -> MutableMappingType
Replaces None values in a dict with a given replacement value. Iterates recursively through nested dicts and iterables.
Untested with iterables other than list, tuple, and set.
Source code in harbor_cli/utils/utils.py
parse_version_string(package: str) -> PackageVersion
Parse a PEP 440 package version string into a PackageVersion tuple.
Must be in the form of <package_name>[{~=,==,!=,<=,>=,<,>}{x.y.z}][,][{~=,==,!=,<=,>=,<,>}{x.y.z}]
Examples:
- "foo"
- "foo==1.2.3"
- "foo>=1.2.3"
- "foo>=1.2.3,<=2.3.4"