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. Could make use for creating an inventory of installed versions of a particular application or finding the latest installed version.
The module offers the 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.0from stringPyCharm-2020.1.0, or version1.0frommy_program_v1.0
AppVersion.Major.Minorversion format
extract_version(version_string="PyCharm-2020.1.0")
> "2020.1.0"
Major.Minorversion 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 present, 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.0The call of such function may look like this:
extract_version(version_string='PyCharm-2018.1.2-windows-10.0', pattern='PyCharm-(.*)-windows-10.0')
> "2018.1.2"
- Create an inventory of installed versions of a particular application
application_path = "C:/Users/user/AppData/Local/JetBrains/PyCharm"
pycharm_versions = available_versions(versions_path=application_path)
> {"2018.1.2": "PyCharm-2018.1.2", "2018.2.0": "PyCharm-2018.2.0", "2020.1.0": "PyCharm-2020.1.0"}
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file extract_version-1.1.0.tar.gz.
File metadata
- Download URL: extract_version-1.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edb80e034947c4dd19c19660999a4fe8618742d3a69b85c0457820f2f8d10595
|
|
| MD5 |
7b2a56d0060d144097b06672037e1b20
|
|
| BLAKE2b-256 |
03846fce9097a77f389f57f0f621cf08ff5247d1c5e5bfe60a2d61cfa98b5051
|
File details
Details for the file extract_version-1.1.0-py3-none-any.whl.
File metadata
- Download URL: extract_version-1.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7b661ed939a59b1497ba52e8dc061ead5b06f3a12040211bc82a9de121f5aa2
|
|
| MD5 |
b2dd1f919d0f8237cfc0ae20a81ff1be
|
|
| BLAKE2b-256 |
db61a081bea86cd62d25169a0578eb876c2e03c195548d225ad8bb40a0fd11cc
|