本文整理汇总了Python中setuptools.dist.Distribution.find_config_files方法的典型用法代码示例。如果您正苦于以下问题:Python Distribution.find_config_files方法的具体用法?Python Distribution.find_config_files怎么用?Python Distribution.find_config_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类setuptools.dist.Distribution
的用法示例。
在下文中一共展示了Distribution.find_config_files方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_config_files
# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import find_config_files [as 别名]
def find_config_files(self):
filenames = _Distribution.find_config_files(self)
env_config_file = os.environ.get(CFG_VAR)
if (env_config_file is not None and not
any(os.path.realpath(f) == os.path.realpath(env_config_file)
for f in filenames)):
filenames.append(env_config_file)
return filenames
示例2: read_configuration
# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import find_config_files [as 别名]
def read_configuration(
filepath, find_others=False, ignore_option_errors=False):
"""Read given configuration file and returns options from it as a dict.
:param str|unicode filepath: Path to configuration file
to get options from.
:param bool find_others: Whether to search for other configuration files
which could be on in various places.
:param bool ignore_option_errors: Whether to silently ignore
options, values of which could not be resolved (e.g. due to exceptions
in directives such as file:, attr:, etc.).
If False exceptions are propagated as expected.
:rtype: dict
"""
if "__PEX_UNVENDORED__" in __import__("os").environ:
from setuptools.dist import Distribution, _Distribution # vendor:skip
else:
from pex.third_party.setuptools.dist import Distribution, _Distribution
filepath = os.path.abspath(filepath)
if not os.path.isfile(filepath):
raise DistutilsFileError(
'Configuration file %s does not exist.' % filepath)
current_directory = os.getcwd()
os.chdir(os.path.dirname(filepath))
try:
dist = Distribution()
filenames = dist.find_config_files() if find_others else []
if filepath not in filenames:
filenames.append(filepath)
_Distribution.parse_config_files(dist, filenames=filenames)
handlers = parse_configuration(
dist, dist.command_options,
ignore_option_errors=ignore_option_errors)
finally:
os.chdir(current_directory)
return configuration_to_dict(handlers)
示例3: find_config_files
# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import find_config_files [as 别名]
def find_config_files(self):
files = Distribution.find_config_files(self)
if 'setup.cfg' in files:
files.remove('setup.cfg')
return files