Python module for extracting version from the string or directory name
Project description
Extract Version
Python module for extracting version from the string or directory name
The module offers following functionality:
- Fetching version string from the string or name of the directory
- Validating version string
- Sorting config and application directories that contain versions in its name
Examples:
- We fetch version
2020.1.0
from stringPyCharm-2020.1.0
, or version1.0
frommy_program_v1.0
.
AppVersion.Major.Minor
version format
extract_version(version_string="PyCharm-2020.1.0")
> "2020.1.0"
Major.Minor
version format
extract_version(version_string="my_program_v1.0")
> "1.0"
- Sort directories by the version of application
sort_versions(["PyCharm-2018.1.2", "PyCharm-2018.2.0", "PyCharm-2020.1.0"])
> ["PyCharm-2018.1.2", "PyCharm-2018.2.0", "PyCharm-2020.1.0"]
- In edge cases with more than one pattern, e.g.
PyCharm-2018.1.2-windows-10.0
, we should provide a clue where the version should be extracted from, in a form of a pattern-regex, e.g.PyCharm-(.*)-windows-10.0
Call of such function may look like:
extract_version(version_string='PyCharm-2018.1.2-windows-10.0', pattern='PyCharm-(.*)-windows-10.0')
> "2018.1.2"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
extract_version-1.0.1.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for extract_version-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f56db500cd1a75d4f7e74435324f2c46c2f955db37c2611157e5a56b93c3d7e7 |
|
MD5 | 7f56434824de58c1d61609a23885b1f3 |
|
BLAKE2b-256 | be95e327a269853647aa8880c44eabe36b7ad0872f5f7a2825a99b4cb2ed2dca |