Metadata-Version: 2.1
Name: text2py
Version: 0.0.2
Summary: Library for processing structured text into python object (dict or list) using templates
Home-page: https://gitlab.com/omaxx/text2py
Author: maxim orlov
Author-email: maxx.orlov@gmail.com
License: MIT License
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.5
Description-Content-Type: text/markdown
Requires-Dist: PyYAML

# Library for processing structured text into python object (dict or list) using templates.

## Using:
```shell script
text2py -t template.yml -i input.txt -o output.txt
```

```python
import text2py
parser = text2py.Parser(template)
output = parser.parse(input_file)
```

## Template format:

Scalar value:
```yaml
- regexp: 'Volume (?P<volume>\w+) Author (?P<author>\w+)'
  key: "{volume}"
  value: "{author}"
```
```python
{volume: author}
```
Dict value
```yaml
- regexp: 'Volume (?P<volume>\w+) Author (?P<author>\w+) Review (?P<review>)'
  key: "volumes.{volume}"
  values:
    - key: 'author'
      value: "{author}"
    - key: 'review'
      value: "{review}"
```
```python
{'volumes' {volume: {'author': author, 'review': review}}}
```



