Skip to main content

a simple tool for ini file crud

Project description

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'])

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

ini_crud-1.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ini_crud-1.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file ini_crud-1.0.0.tar.gz.

File metadata

  • Download URL: ini_crud-1.0.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.6

File hashes

Hashes for ini_crud-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3bd85f9f952d5670ba0817ce9513a2bb4254df87ca66f93a268d0bd724a7ce4a
MD5 4f82ba7565b423d0b7ffa6af0444bdf5
BLAKE2b-256 c900fee1bda76785bf4d0dc3f61ccd8a5993d9545ccbc7217ee4948187dd1259

See more details on using hashes here.

File details

Details for the file ini_crud-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ini_crud-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.6

File hashes

Hashes for ini_crud-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c78700afc47f101506a36b82b50bfebcaeb29c4d5ea818cefbcf3172376717b0
MD5 bda25a3180f38e52f6fdab40993b3b24
BLAKE2b-256 6c8159cbb5016fbefa741e55cdc7ef30eee38c36f27495ffc95bc2a0bbab2e64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page