Reverse-engineer the values of a string based on a template
Project description
pytemplate-reverse
A package to "reverse-enginner" simple strings based on a template.
Reverse-engineer a string based on a template, can be usefull to extract information from a generated string when you know how the information will be formated in said string, like the a file name.
Usage sample:
from template_reverse import ReverseTemplate
segments = [
"shrek3_0_600.avi",
"shrek3_1_560.avi",
"shrek3_2_780.avi"
]
rt = ReverseTemplate("{video_name}_{segment_id}_{segment_duration_in_secs}.avi")
total_duration = 0
for segment in segments:
values = rt.reverse(segment)
print("Checking out movie", values["video_name"], "part ", values["segment_id"])
total_duration += int(values["segment_duration_in_secs"])
print("Total video duration so far", total_duration)
Build locally
Requires Python 3.
This package is simple enough that it should work with any version. I recommend you to install python using pyenv with pyenv-virtualenv. If you are on windows check pyenv-win out.
Install
cd /path/to/pytemplate-reverse
pip install . # Thats it :)
If you want to develop on it and run tests use the following:
pip install -r test-requirements.txt -e .
# `-r test-requirements.txt` Will install the dependencies required to run the tests
# `-e .` Install in editable mode, so you can edit the contents of /src/pytemplate_reverse without having to install the package again to see changes
pytest
To get coverage and lint run pytest with the following plugins:
pytest --black --cov=template_reverse
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
File details
Details for the file pytemplate_reverse-0.0.3.tar.gz
.
File metadata
- Download URL: pytemplate_reverse-0.0.3.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f62d2938cda497a2cebf8f2bdbdc10f2028320388f479545500d055dfb55e64 |
|
MD5 | 8455ca198b898a6da5391092ebe18668 |
|
BLAKE2b-256 | afa71947ed396c99e45efb709eac3c502d81a98853a8f4ccab449478b3a84acf |
File details
Details for the file pytemplate_reverse-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pytemplate_reverse-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ae4181eb772854c5c53b37f7bee6d7b8aa8e2471b7c0ea3ef3933dcdc2b2664 |
|
MD5 | e93b3a1633401dad93458a439bcf0c22 |
|
BLAKE2b-256 | 38b6991cf8507fe55022e888f7d146eaf41a4a2481ba9b556f799fd3efd64de3 |