本文整理汇总了Python中logging.config.valid_ident方法的典型用法代码示例。如果您正苦于以下问题:Python config.valid_ident方法的具体用法?Python config.valid_ident怎么用?Python config.valid_ident使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logging.config
的用法示例。
在下文中一共展示了config.valid_ident方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: valid_ident
# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import valid_ident [as 别名]
def valid_ident(s):
m = IDENTIFIER.match(s)
if not m:
raise ValueError('Not a valid Python identifier: %r' % s)
return True
# The ConvertingXXX classes are wrappers around standard Python containers,
# and they serve to convert any suitable values in the container. The
# conversion converts base dicts, lists and tuples to their wrapped
# equivalents, whereas strings which match a conversion format are converted
# appropriately.
#
# Each wrapper should have a configurator attribute holding the actual
# configurator to use for conversion.
示例2: configure_custom
# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import valid_ident [as 别名]
def configure_custom(self, config):
"""Configure an object with a user-supplied factory."""
c = config.pop('()')
if not callable(c):
c = self.resolve(c)
props = config.pop('.', None)
# Check for valid identifiers
kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
result = c(**kwargs)
if props:
for name, value in props.items():
setattr(result, name, value)
return result