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__))}
```
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
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
pyyml-0.0.2.tar.gz
(1.4 kB
view hashes)
Built Distribution
Close
Hashes for pyyml-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17acc886bb8d58197a745003eae477b18b343ebaa0a304527c5a5dc5770a2b74 |
|
MD5 | a9d0c2af4917bc1af87651056d8b1eb9 |
|
BLAKE2b-256 | 20c43996ead5533b19da63409c0e5e56827f0e5ed8228c771d587ac98c63c157 |