ini_crud
Description
ini_crud is a simple crud library for dart.
Install
pip install ini_crud
Usage
增删改
# 新增文件,设置 section 和 option
ini_crud dest=/etc/anotherconf2 section=drinks option=db value=hu state=present create=yes
# 更新文件,设置 section 和 option 多个值
ini_crud dest=/etc/anotherconf2 section=drinks option=db value=hu1,hu2 state=present diff=yes
# 删除文件中设置 section 和 option
ini_crud dest=/etc/anotherconf2 section=drinks option=db value=hu state=absent
# 修改文件,设置 section 和 option,并开启备份
ini_crud dest=/etc/anotherconf2 section=drinks option=name value=hu1111 state=present
ini_crud dest=/etc/anotherconf2 section=drinks option=db value=hu2222 state=present backup=yes
# 修改文件,设置 section 和 option,并开启备份,允许空值
ini_crud dest=/etc/anotherconf2 section=drinks option=name2 value= state=present allow_no_value=yes
ini_crud dest=/etc/anotherconf2 section=drinks option=name2 value= state=present backup=yes allow_no_value=yes
# 修改文件,设置 section 和 option,开启 diff
ini_crud dest=/etc/anotherconf2 section=drinks option=db value=hu111111111 state=present diff=yes
# 修改文件,设置 section 和 option,并开启备份,允许空值,开启 diff, 并设置 no_extra_spaces
ini_crud dest=/etc/anotherconf2 section=drinks option=db value=localhost state=present backup=yes no_extra_spaces=yes create=yes allow_no_value=yes diff=yes
查
# 查询文件,根据 section 和 option 查询
ini_crud dest=/etc/anotherconf2 section=drinks option=db mode=get
# 查询文件,查询 所有 section 下的 option
ini_crud dest=/etc/anotherconf2 section=drinks mode=get
方法调用
from ini_crud import do_ini, backup_local, match_opt, match_active_opt, get_ini_lines
if __name__ == '__main__':
do_ini("/etc/hosts", section="test", option="test", value="test", state="present")
do_ini("/etc/anotherconf", section="test", option="test", value="test", state="present")
do_ini("/etc/anotherconf", section="drinks", option="db", value="hu", state="present", backup=True)
do_ini("/etc/anotherconf", section="drinks", option="name", value="hu", state="present", backup=True, _diff=True)
do_ini("/etc/anotherconf", section="drinks", option="db3", value="", state="present", backup=True,
allow_no_value=True)
do_ini("/etc/anotherconf", section="drinks", option="db2", value="hu2", state="present", backup=True,
no_extra_spaces=True)
changed, backup_file, diff, msg = do_ini("/etc/anotherconf2", section="drinks", option="db", mode="get")
print(changed, backup_file, diff, msg['options'])
Metadata
Release files for ini-crud 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ini_crud-1.0.0.tar.gz | 10.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ini_crud-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.5 kB
Release files / ini_crud-1.0.0.tar.gz
| Download URL | ini_crud-1.0.0.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bd85f9f952d5670ba0817ce9513a2bb4254df87ca66f93a268d0bd724a7ce4a
|
|
BLAKE2b-256 checksum How to use checksums |
c900fee1bda76785bf4d0dc3f61ccd8a5993d9545ccbc7217ee4948187dd1259
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.6
|
Release files / ini_crud-1.0.0-py3-none-any.whl
| Download URL | ini_crud-1.0.0-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c78700afc47f101506a36b82b50bfebcaeb29c4d5ea818cefbcf3172376717b0
|
|
BLAKE2b-256 checksum How to use checksums |
6c8159cbb5016fbefa741e55cdc7ef30eee38c36f27495ffc95bc2a0bbab2e64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.6
|