Skip to main content

Use python in yaml

Project description

# pyyml
Use python in yaml
## 基本使用
在python中使用:
```python
from pyyml import load

with open('conf.yml') as f:
raw_conf = f.read()
config = load(raw_conf)
print(config)
```
在yaml中 `${...}` 中的内容将会被python执行:

yaml内容
```yaml
sum: ${1 + 1}
```
实际解析内容
```python
{'sum': 2}
```
通过在文件开头第一行注释来导入所需的包:

```yaml
# libs:['os', 'os.path:path', 'this']
```
通过 [包名]:[别名] 取别名导入包

`'os.path:path' 等同于 python 中的 from os import path`

例如yaml文件内容
```yaml
# libs:['os', 'os.path:path', 'this']
os_name: ${os.name}
base_dir: ${path.abspath(path.dirname(__file__))}
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyyml, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size pyyml-0.0.2-py2.py3-none-any.whl (1.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size pyyml-0.0.2.tar.gz (1.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page