简单文本配置文件读/写
textconfig的Python项目详细描述
textconfig
textconfig是一个用于管理简单文本配置文件的类 Python。简单地说,这意味着它们是简单的文本文件 配置文件中没有节和所有选项使用严格的
OPTION=value
格式,在OPTION
、=
和value
之间没有空格。
同一个OPTION
可以多次使用,因此可以有多个
值,例如:
EXAMPLE=one
EXAMPLE=two
下面是这样一个文件的真实示例,取自slapt-get
包
salix中的管理器存储库配置文件:
# Working directory for local storage/cache.
WORKINGDIR=/var/slapt-get
# Exclude package names and expressions.
# To exclude pre and beta packages, add this to the exclude:
# [0-9\_\.\-]{1}pre[0-9\-\.\-]{1}
EXCLUDE=^aaa_elflibs,^aaa_base,^devs,^glibc.*,^kernel-.*,^rootuser-settings,^zzz-settings.*,-i?86-
# The Slackware repositories, including dependency information
SOURCE=http://www.mirrorservice.org/sites/download.salixos.org/x86_64/slackware-14.2/:OFFICIAL
SOURCE=http://www.mirrorservice.org/sites/download.salixos.org/x86_64/slackware-14.2/extra/:OFFICIAL
# The Salix repository
SOURCE=http://www.mirrorservice.org/sites/download.salixos.org/x86_64/14.2/:PREFERRED
# And the Salix extra repository
SOURCE=http://www.mirrorservice.org/sites/download.salixos.org/x86_64/extra-14.2/:OFFICIAL
您可以这样称呼它:
from textconfig import TextConfig
c = TextConfig('/path/to/configfile')