Git Product home page Git Product logo

pytemplate-reverse's Introduction

pytemplate-reverse

PyPI version Build Status codecov

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

pytemplate-reverse's People

Contributors

yvdlima avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.