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 details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyyml-0.0.2.tar.gz.
File metadata
- Download URL: pyyml-0.0.2.tar.gz
- Upload date:
- Size: 1.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f005c753eb36a405321eb653d803861c8570c347f89b35a7c9c21edef5248f5f
|
|
| MD5 |
90338e2d10dc10caa62c6c3b0128ca2d
|
|
| BLAKE2b-256 |
370306f9809cf57ef6fdffe11a4bf7c0c092835913da05bfce9d618ac6f714af
|
File details
Details for the file pyyml-0.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: pyyml-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 1.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17acc886bb8d58197a745003eae477b18b343ebaa0a304527c5a5dc5770a2b74
|
|
| MD5 |
a9d0c2af4917bc1af87651056d8b1eb9
|
|
| BLAKE2b-256 |
20c43996ead5533b19da63409c0e5e56827f0e5ed8228c771d587ac98c63c157
|