本文整理汇总了Python中six.moves.configparser.ConfigParser.has_section方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.has_section方法的具体用法?Python ConfigParser.has_section怎么用?Python ConfigParser.has_section使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six.moves.configparser.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.has_section方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: INIReader
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
class INIReader(object):
"""ConfigParser wrapper able to cast value when reading INI options."""
# Helper casters
cast_boolean = casts.Boolean()
cast_dict = casts.Dict()
cast_list = casts.List()
cast_logging_level = casts.LoggingLevel()
cast_tuple = casts.Tuple()
cast_webdriver_desired_capabilities = casts.WebdriverDesiredCapabilities()
def __init__(self, path):
self.config_parser = ConfigParser()
with open(path) as handler:
self.config_parser.readfp(handler)
if sys.version_info[0] < 3:
# ConfigParser.readfp is deprecated on Python3, read_file
# replaces it
self.config_parser.readfp(handler)
else:
self.config_parser.read_file(handler)
def get(self, section, option, default=None, cast=None):
"""Read an option from a section of a INI file.
The default value will return if the look up option is not available.
The value will be cast using a callable if specified otherwise a string
will be returned.
:param section: Section to look for.
:param option: Option to look for.
:param default: The value that should be used if the option is not
defined.
:param cast: If provided the value will be cast using the cast
provided.
"""
try:
value = self.config_parser.get(section, option)
if cast is not None:
if cast is bool:
value = self.cast_boolean(value)
elif cast is dict:
value = self.cast_dict(value)
elif cast is list:
value = self.cast_list(value)
elif cast is tuple:
value = self.cast_tuple(value)
else:
value = cast(value)
except (NoSectionError, NoOptionError):
value = default
return value
def has_section(self, section):
"""Check if section is available."""
return self.config_parser.has_section(section)
示例2: test_empty_dict
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
def test_empty_dict(self):
name = self.make_empty_temp_file()
to_config_file(name, "section.name", {})
self.assertTrue(os.path.isfile(name))
config = ConfigParser()
config.read(name)
self.assertTrue(config.has_section("section.name"))
self.assertSetEqual(_VALID_KEYS, set(config.options("section.name")))
示例3: test_partial_dict
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
def test_partial_dict(self):
name = self.make_empty_temp_file()
to_config_file(name, "section.name", {"port_queue_dt": 1.})
self.assertTrue(os.path.isfile(name))
config = ConfigParser()
config.read(name)
self.assertTrue(config.has_section("section.name"))
self.assertSetEqual(_VALID_KEYS, set(config.options("section.name")))
self.assertEqual(1., config.getfloat("section.name", "port_queue_dt"))
示例4: load_ini
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
def load_ini(self, ini_config):
"""
Read the provided ini contents arguments and merge
the data in the ini config into the config object.
ini_config is assumed to be a string of the ini file contents.
"""
parser = ConfigParser()
parser.readfp(StringIO(ini_config))
data = {
'linters': {},
'files': {},
'branches': {},
'fixers': {},
'review': {}
}
if parser.has_section('files'):
ignore = parser.get('files', 'ignore')
data['files']['ignore'] = newline_value(ignore)
if parser.has_section('branches'):
ignore = parser.get('branches', 'ignore')
data['branches']['ignore'] = comma_value(ignore)
linters = []
if parser.has_section('tools'):
linters = comma_value(parser.get('tools', 'linters'))
if parser.has_section('fixers'):
data['fixers'] = dict(parser.items('fixers'))
if parser.has_section('review'):
data['review'] = dict(parser.items('review'))
# Setup empty config sections
for linter in linters:
data['linters'][linter] = {}
for section in parser.sections():
if not section.startswith('tool_'):
continue
# Strip off tool_
linter = section[5:]
data['linters'][linter] = dict(parser.items(section))
self.update(data)
示例5: test_ignore_extra_params
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
def test_ignore_extra_params(self):
name = self.make_empty_temp_file()
to_config_file(
name, "section.name", {"invalid_parameter": "empty", "port_queue_dt": 1.2}
)
self.assertTrue(os.path.isfile(name))
config = ConfigParser()
config.read(name)
self.assertTrue(config.has_section("section.name"))
self.assertSetEqual(_VALID_KEYS, set(config.options("section.name")))
self.assertEqual(1.2, config.getfloat("section.name", "port_queue_dt"))
self.assertFalse(config.has_option("section.name", "invalid_parameter"))
示例6: load
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
def load(self):
schemes = [defaultScheme]
parser = ConfigParser()
parser.read(settings.DASHBOARD_CONF)
for option, default_value in defaultUIConfig.items():
if parser.has_option('ui', option):
try:
self.ui_config[option] = parser.getint('ui', option)
except ValueError:
self.ui_config[option] = parser.get('ui', option)
else:
self.ui_config[option] = default_value
if parser.has_option('ui', 'automatic_variants'):
self.ui_config['automatic_variants'] = parser.getboolean('ui', 'automatic_variants')
else:
self.ui_config['automatic_variants'] = True
self.ui_config['keyboard_shortcuts'] = defaultKeyboardShortcuts.copy()
if parser.has_section('keyboard-shortcuts'):
self.ui_config['keyboard_shortcuts'].update( parser.items('keyboard-shortcuts') )
for section in parser.sections():
if section in ('ui', 'keyboard-shortcuts'):
continue
scheme = parser.get(section, 'scheme')
fields = []
for match in fieldRegex.finditer(scheme):
field = match.group(1)
if parser.has_option(section, '%s.label' % field):
label = parser.get(section, '%s.label' % field)
else:
label = field
fields.append({
'name' : field,
'label' : label
})
schemes.append({
'name' : section,
'pattern' : scheme,
'fields' : fields,
})
self.schemes = schemes
示例7: run
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
def run(self, args, **kwargs):
if not args.password:
args.password = getpass.getpass()
instance = self.resource(ttl=args.ttl) if args.ttl else self.resource()
cli = BaseCLIApp()
# Determine path to config file
try:
config_file = cli._get_config_file_path(args)
except ValueError:
# config file not found in args or in env, defaulting
config_file = config_parser.ST2_CONFIG_PATH
# Retrieve token
manager = self.manager.create(instance, auth=(args.username, args.password), **kwargs)
cli._cache_auth_token(token_obj=manager)
# Update existing configuration with new credentials
config = ConfigParser()
config.read(config_file)
# Modify config (and optionally populate with password)
if not config.has_section('credentials'):
config.add_section('credentials')
config.set('credentials', 'username', args.username)
if args.write_password:
config.set('credentials', 'password', args.password)
else:
# Remove any existing password from config
config.remove_option('credentials', 'password')
with open(config_file, 'w') as cfg_file_out:
config.write(cfg_file_out)
return manager
示例8: SetupConfig
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
class SetupConfig(object):
"""Wrapper around the setup.cfg file if available.
One reason is to cleanup setup.cfg from these settings::
[egg_info]
tag_build = dev
tag_svn_revision = true
Another is for optional zest.releaser-specific settings::
[zest.releaser]
no-input = yes
"""
config_filename = SETUP_CONFIG_FILE
def __init__(self):
"""Grab the configuration (overridable for test purposes)"""
# If there is a setup.cfg in the package, parse it
if not os.path.exists(os.path.join(utils.PACKAGE_ROOT, self.config_filename)):
self.config = None
return
self.config = ConfigParser()
with codecs.open(self.config_filename, 'r', 'utf8') as fp:
self.config.readfp(fp)
def has_bad_commands(self):
if self.config is None:
return False
if not self.config.has_section('egg_info'):
# bail out early as the main section is not there
return False
bad = False
# Check 1.
if self.config.has_option('egg_info', 'tag_build'):
# Might still be empty.
value = self.config.get('egg_info', 'tag_build')
if value:
logger.warn("%s has [egg_info] tag_build set to %r",
self.config_filename, value)
bad = True
# Check 2.
if self.config.has_option('egg_info', 'tag_svn_revision'):
if self.config.getboolean('egg_info', 'tag_svn_revision'):
value = self.config.get('egg_info', 'tag_svn_revision')
logger.warn("%s has [egg_info] tag_svn_revision set to %r",
self.config_filename, value)
bad = True
return bad
def fix_config(self):
if not self.has_bad_commands():
logger.warn("Cannot fix already fine %s.", self.config_filename)
return
if self.config.has_option('egg_info', 'tag_build'):
self.config.set('egg_info', 'tag_build', '')
if self.config.has_option('egg_info', 'tag_svn_revision'):
self.config.set('egg_info', 'tag_svn_revision', 'false')
new_setup = open(self.config_filename, 'w')
try:
self.config.write(new_setup)
finally:
new_setup.close()
logger.info("New setup.cfg contents:")
print(''.join(open(self.config_filename).readlines()))
def no_input(self):
"""Return whether the user wants to run in no-input mode.
Enable this mode by adding a ``no-input`` option::
[zest.releaser]
no-input = yes
The default when this option has not been set is False.
Standard config rules apply, so you can use upper or lower or
mixed case and specify 0, false, no or off for boolean False,
and 1, on, true or yes for boolean True.
"""
default = False
if self.config is None:
return default
try:
result = self.config.getboolean('zest.releaser', 'no-input')
except (NoSectionError, NoOptionError, ValueError):
return default
return result
def python_file_with_version(self):
"""Return Python filename with ``__version__`` marker, if configured.
Enable this by adding a ``python-file-with-version`` option::
[zest.releaser]
python-file-with-version = reinout/maurits.py
#.........这里部分代码省略.........
示例9: PypiConfig
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
class PypiConfig(BaseConfig):
"""Wrapper around the pypi config file"""
def __init__(self, config_filename=DIST_CONFIG_FILE, use_setup_cfg=True):
"""Grab the PyPI configuration.
This is .pypirc in the home directory. It is overridable for
test purposes.
If there is a setup.cfg file in the current directory, we read
it too.
"""
self.config_filename = config_filename
self.use_setup_cfg = use_setup_cfg
self.reload()
def reload(self):
"""Load the config.
Do the initial load of the config.
Or reload it in case of problems: this is needed when a pypi
upload fails, you edit the .pypirc file to fix the account
settings, and tell release to retry the command.
"""
self._read_configfile(use_setup_cfg=self.use_setup_cfg)
def _read_configfile(self, use_setup_cfg=True):
"""Read the PyPI config file and store it (when valid).
Usually read the setup.cfg too.
"""
rc = self.config_filename
if not os.path.isabs(rc):
rc = os.path.join(os.path.expanduser('~'), self.config_filename)
filenames = [rc]
if use_setup_cfg:
# If there is a setup.cfg in the package, parse it
filenames.append('setup.cfg')
files = [f for f in filenames if os.path.exists(f)]
if not files:
self.config = None
return
self.config = ConfigParser()
self.config.read(files)
def is_pypi_configured(self):
# Do we have configuration for releasing to at least one
# pypi-compatible server?
if self.config is None:
return False
return len(self.distutils_servers()) > 0
def distutils_servers(self):
"""Return a list of known distutils servers.
If the config has an old pypi config, remove the default pypi
server from the list.
"""
try:
index_servers = self._get_text(
'distutils', 'index-servers', default='').split()
except (NoSectionError, NoOptionError):
index_servers = []
if not index_servers:
# If no distutils index-servers have been given, 'pypi' should be
# the default. This is what twine does.
if self.config.has_option('server-login', 'username'):
# We have a username, so upload to pypi should work fine, even
# when no explicit pypi section is in the file.
return ['pypi']
# https://github.com/zestsoftware/zest.releaser/issues/199
index_servers = ['pypi']
# The servers all need to have a section in the config file.
return [server for server in index_servers
if self.config.has_section(server)]
def want_release(self):
"""Does the user normally want to release this package.
Some colleagues find it irritating to have to remember to
answer the question "Check out the tag (for tweaks or
pypi/distutils server upload)" with the non-default 'no' when
in 99 percent of the cases they just make a release specific
for a customer, so they always answer 'no' here. This is
where an extra config option comes in handy: you can influence
the default answer so you can just keep hitting 'Enter' until
zest.releaser is done.
Either in your ~/.pypirc or in a setup.cfg in a specific
package, add this when you want the default answer to this
question to be 'no':
[zest.releaser]
release = no
The default when this option has not been set is True.
Standard config rules apply, so you can use upper or lower or
mixed case and specify 0, false, no or off for boolean False,
#.........这里部分代码省略.........
示例10: load
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
def load(cfg_file=None, environment=None, overrides=None):
"""
Load configuration.
A configuration file consists of sections, led by a ``[section]`` header
and followed by ``name: value`` entries. Lines beginning with ``'#'`` are
ignored and may be used to provide comments.
A configuration file can contain multiple sections. The configuration
object is populated with values from the ``global`` section and additional
sections based on the fully qualified domain name of the local host. For
example, on the host ``tin.eqiad.wmnet`` the final value for a given
setting would be the first value found in sections: ``tin.eqiad.wmnet``,
``eqiad.wmnet``, ``wmnet`` or ``global``. Sections not present in the
configuration file will be ignored.
Configuration values are loaded from a file specified by the ``-c`` or
``--conf`` command-line options or from the default locations with the
following hierarchy, sorted by override priority:
#. ``$(pwd)/scap/environments/<environment>/scap.cfg`` or
``$(pwd)/scap/scap.cfg`` (if no environment was specified)
#. ``/etc/scap.cfg``
For example, if a configuration parameter is set in
``$(pwd)/scap/scap.cfg`` and that same parameter is set in
``/etc/scap.cfg`` the value for that parameter set in
``$(pwd)/scap/scap.cfg`` will be used during execution.
:param cfg_file: Alternate configuration file
:param environment: the string path under which scap.cfg is found
:param overrides: Dict of configuration values
:returns: dict of configuration values
"""
local_cfg = os.path.join(os.getcwd(), 'scap')
parser = ConfigParser()
if cfg_file:
try:
cfg_file = open(cfg_file)
except TypeError:
# Assume that cfg_file is already an open file
pass
parser.readfp(cfg_file)
else:
parser.read([
'/etc/scap.cfg',
os.path.join(local_cfg, 'scap.cfg'),
utils.get_env_specific_filename(
os.path.join(local_cfg, 'scap.cfg'),
environment
)
])
fqdn = socket.getfqdn().split('.')
sections = ['global']
sections += ['.'.join(fqdn[l:]) for l in range(0, len(fqdn))][::-1]
config = {key: value for key, (_, value) in DEFAULT_CONFIG.items()}
for section in sections:
if parser.has_section(section):
# Do not interpolate items in the section.
# Fixes crash on tin: 'int' object has no attribute 'find'
for key, value in parser.items(section, True):
config[key] = coerce_value(key, value)
config = override_config(config, overrides)
if not environment and config.get('environment', None):
return load(cfg_file, config.get('environment'), overrides)
config['environment'] = environment
return config
示例11: ConfigParser
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
class OpenLDAP2:
library_dirs = []
include_dirs = []
extra_compile_args = []
extra_link_args = []
extra_objects = []
libs = ['ldap', 'lber']
defines = [ ]
extra_files = []
LDAP_CLASS = OpenLDAP2
#-- Read the [_ldap] section of setup.cfg
cfg = ConfigParser()
cfg.read('setup.cfg')
if cfg.has_section('_ldap'):
for name in dir(LDAP_CLASS):
if cfg.has_option('_ldap', name):
print(name + ': ' + cfg.get('_ldap', name))
setattr(LDAP_CLASS, name, cfg.get('_ldap', name).split())
for i in range(len(LDAP_CLASS.defines)):
LDAP_CLASS.defines[i]=((LDAP_CLASS.defines[i],None))
for i in range(len(LDAP_CLASS.extra_files)):
destdir, origfiles = LDAP_CLASS.extra_files[i].split(':')
origfileslist = origfiles.split(',')
LDAP_CLASS.extra_files[i]=(destdir, origfileslist)
#-- Let distutils/setuptools do the rest
name = 'python-ldap'
示例12: Configuration
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
class Configuration(object):
defaults = {}
def __init__(self, filename=None):
self._config = ConfigParser()
self._set_defaults()
self._state_drivers = {}
if filename is not None:
self.load(filename)
def _set_defaults(self):
"""Set defaults for config
"""
self._config.add_section('main')
for key, value in six.iteritems(self.defaults):
if isinstance(value, dict):
self._config.add_section(key)
for subkey, subvalue in six.iteritems(value):
self._config.set(key, subkey, subvalue)
else:
self._config.set('main', key, value)
def load(self, filename):
"""Load the configuration by filename
"""
self._config.read(filename)
def save(self, filename):
"""Save the configuration to a file
"""
with open(filename, 'w') as handle:
self._config.write(handle)
@staticmethod
def sanitize(items):
options = {}
for key, value in items:
if key.endswith('[int]'):
options[key[:-5]] = int(value)
elif key.endswith('[bool]'):
value = value.lower()
if value in BOOL_MAP[True]:
value = True
elif value in BOOL_MAP[False]:
value = False
else:
raise ValueError('Expected boolean for {}'.format(key))
options[key[:-6]] = value
else:
options[key] = value
return options
def __getitem__(self, name):
if self._config.has_section(name):
return self.sanitize(self._config.items(name))
elif name == 'main':
raise ValueError('Missing main section of configuration')
return self['main'][name]
def state_driver(self, name='ai'):
"""Get an instance of the state driver
"""
from database import state
if name not in self._state_drivers:
extras = self[name]
driver = extras.pop('state-driver')
if driver == 'redis':
self._state_drivers[name] = state.RedisDriver(self, extras)
elif driver == 'dict':
self._state_drivers[name] = state.MemoryDriver(self, extras)
else:
raise ValueError('Unknown state driver')
return self._state_drivers[name]
示例13: StationConfig
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
class StationConfig(object):
# sections name ordered?
__sects = OrderedDict((('setup', False),
('server', False),
('positioners', True),
('detectors', True),
('counters', True),
('xafs', False),
('slewscan', False),
('slewscan_positioners', True),
('extrapvs', True),
))
def __init__(self, filename=None, text=None):
for s in self.__sects:
setattr(self, s, {})
self._cp = ConfigParser()
if filename is None:
filename = DEF_CONFFILE
self.filename = filename
# print 'StationConfig ', filename, os.path.abspath(filename)
# print os.path.exists(filename), os.path.isfile(filename)
if (os.path.exists(filename) and
os.path.isfile(filename)):
ret = self._cp.read(filename)
if len(ret) == 0:
time.sleep(0.1)
self._cp.read(filename)
else:
self._cp.readfp(StringIO(DEFAULT_CONF))
self.Read()
def Read(self, filename=None):
"read config"
if (filename is not None and
(os.path.exists(filename) and
os.path.isfile(filename))):
ret = self._cp.read(filename)
if len(ret) == 0:
time.sleep(0.1)
self._cp.read(filename)
self.filename = filename
# process sections
for sect, ordered in self.__sects.items():
if not self._cp.has_section(sect):
continue
thissect = {}
opt_keys = self._cp.options(sect)
if ordered:
thissect = OrderedDict()
opt_keys.sort()
for opt in opt_keys:
val = self._cp.get(sect, opt)
if '||' in val:
words = [i.strip() for i in val.split('||')]
label = words.pop(0)
if len(words) == 1:
words = words[0]
else:
tmp = []
for w in words:
if ',' in w and '=' in w:
tmp.append(opts2dict(w))
else:
tmp.append(w)
words = tuple(tmp)
thissect[label] = words
else:
thissect[opt] = val
setattr(self, sect, thissect)
for key, val in self.positioners.items():
fi = []
if isinstance(val, (list, tuple)):
for v in val:
if '.' not in v: v = '%s.VAL' % v
fi.append(v)
else:
if '.' not in val:
val = '%s.VAL' % val
fi = [val, val]
self.positioners[key] = tuple(fi)
def Save(self, fname=None):
"save config file"
if fname is not None:
self.filename = fname
if fname is None:
fname = self.filename = DEF_CONFFILE
path, fn = os.path.split(fname)
if not os.path.exists(path):
os.makedirs(path, mode=0o755)
out = ['### %s: %s' % (TITLE, get_timestamp())]
for sect, ordered in self.__sects.items():
out.append('#------------------------------#\n[%s]' % sect)
if sect in ('setup', 'server', 'slewscan', 'xafs'):
for name, val in self.setup.items():
out.append("%s = %s" % (name, val))
#.........这里部分代码省略.........
示例14: _get_names_from_config
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
def _get_names_from_config(self, cp, section):
config = ConfigParser()
config.read(cp)
if config.has_section(section):
return [config.get(section, option) for option in config.options(section)]
示例15: SetupConfig
# 需要导入模块: from six.moves.configparser import ConfigParser [as 别名]
# 或者: from six.moves.configparser.ConfigParser import has_section [as 别名]
class SetupConfig(object):
"""Wrapper around the setup.cfg file if available.
One reason is to cleanup setup.cfg from these settings::
[egg_info]
tag_build = dev
tag_svn_revision = true
Another is for optional zest.releaser-specific settings::
[zest.releaser]
python-file-with-version = reinout/maurits.py
"""
config_filename = SETUP_CONFIG_FILE
def __init__(self):
"""Grab the configuration (overridable for test purposes)"""
# If there is a setup.cfg in the package, parse it
if not os.path.exists(self.config_filename):
self.config = None
return
self.config = ConfigParser()
with codecs.open(self.config_filename, 'r', 'utf8') as fp:
self.config.readfp(fp)
def development_marker(self):
"""Return development marker to be appended in postrelease
Override the default ``.dev0`` in setup.cfg using
a ``development-marker`` option::
[zest.releaser]
development-marker = .dev1
Returns default of `.dev0` when nothing has been configured.
"""
try:
result = self.config.get('zest.releaser',
'development-marker')
except (NoSectionError, NoOptionError, ValueError):
result = ".dev0"
return result
def has_bad_commands(self):
if self.config is None:
return False
if not self.config.has_section('egg_info'):
# bail out early as the main section is not there
return False
bad = False
# Check 1.
if self.config.has_option('egg_info', 'tag_build'):
# Might still be empty.
value = self.config.get('egg_info', 'tag_build')
if value:
logger.warn("%s has [egg_info] tag_build set to %r",
self.config_filename, value)
bad = True
# Check 2.
if self.config.has_option('egg_info', 'tag_svn_revision'):
if self.config.getboolean('egg_info', 'tag_svn_revision'):
value = self.config.get('egg_info', 'tag_svn_revision')
logger.warn("%s has [egg_info] tag_svn_revision set to %r",
self.config_filename, value)
bad = True
return bad
def fix_config(self):
if not self.has_bad_commands():
logger.warn("Cannot fix already fine %s.", self.config_filename)
return
if self.config.has_option('egg_info', 'tag_build'):
self.config.set('egg_info', 'tag_build', '')
if self.config.has_option('egg_info', 'tag_svn_revision'):
self.config.set('egg_info', 'tag_svn_revision', 'false')
new_setup = open(self.config_filename, 'w')
try:
self.config.write(new_setup)
finally:
new_setup.close()
logger.info("New setup.cfg contents:")
print(''.join(open(self.config_filename).readlines()))
def python_file_with_version(self):
"""Return Python filename with ``__version__`` marker, if configured.
Enable this by adding a ``python-file-with-version`` option::
[zest.releaser]
python-file-with-version = reinout/maurits.py
Return None when nothing has been configured.
"""
default = None
#.........这里部分代码省略.........