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.

Source Distribution

pyyml-0.0.2.tar.gz (1.4 kB view hashes)

Uploaded source

Built Distribution

pyyml-0.0.2-py2.py3-none-any.whl (1.5 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page