当前位置: 首页>>代码示例>>Python>>正文


Python util.basestring_type方法代码示例

本文整理汇总了Python中tornado.util.basestring_type方法的典型用法代码示例。如果您正苦于以下问题:Python util.basestring_type方法的具体用法?Python util.basestring_type怎么用?Python util.basestring_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.util的用法示例。


在下文中一共展示了util.basestring_type方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def parse(self, value):
        _parse = {
            datetime.datetime: self._parse_datetime,
            datetime.timedelta: self._parse_timedelta,
            bool: self._parse_bool,
            basestring_type: self._parse_string,
        }.get(self.type, self.type)
        if self.multiple:
            self._value = []
            for part in value.split(","):
                if issubclass(self.type, numbers.Integral):
                    # allow ranges of the form X:Y (inclusive at both ends)
                    lo, _, hi = part.partition(":")
                    lo = _parse(lo)
                    hi = _parse(hi) if hi else lo
                    self._value.extend(range(lo, hi + 1))
                else:
                    self._value.append(_parse(part))
        else:
            self._value = _parse(value)
        if self.callback is not None:
            self.callback(self._value)
        return self.value() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:25,代码来源:options.py

示例2: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def __init__(self, logger, regex, required=True):
        """Constructs an ExpectLog context manager.

        :param logger: Logger object (or name of logger) to watch.  Pass
            an empty string to watch the root logger.
        :param regex: Regular expression to match.  Any log entries on
            the specified logger that match this regex will be suppressed.
        :param required: If true, an exeption will be raised if the end of
            the ``with`` statement is reached without matching any log entries.
        """
        if isinstance(logger, basestring_type):
            logger = logging.getLogger(logger)
        self.logger = logger
        self.regex = re.compile(regex)
        self.required = required
        self.matched = False
        self.logged_stack = False 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:19,代码来源:testing.py

示例3: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def __init__(
        self,
        logger: Union[logging.Logger, basestring_type],
        regex: str,
        required: bool = True,
    ) -> None:
        """Constructs an ExpectLog context manager.

        :param logger: Logger object (or name of logger) to watch.  Pass
            an empty string to watch the root logger.
        :param regex: Regular expression to match.  Any log entries on
            the specified logger that match this regex will be suppressed.
        :param required: If true, an exception will be raised if the end of
            the ``with`` statement is reached without matching any log entries.
        """
        if isinstance(logger, basestring_type):
            logger = logging.getLogger(logger)
        self.logger = logger
        self.regex = re.compile(regex)
        self.required = required
        self.matched = False
        self.logged_stack = False 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:24,代码来源:testing.py

示例4: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def __init__(self, logger, regex, required=True):
        """Constructs an ExpectLog context manager.

        :param logger: Logger object (or name of logger) to watch.  Pass
            an empty string to watch the root logger.
        :param regex: Regular expression to match.  Any log entries on
            the specified logger that match this regex will be suppressed.
        :param required: If true, an exeption will be raised if the end of
            the ``with`` statement is reached without matching any log entries.
        """
        if isinstance(logger, basestring_type):
            logger = logging.getLogger(logger)
        self.logger = logger
        self.regex = re.compile(regex)
        self.required = required
        self.matched = False 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:18,代码来源:testing.py

示例5: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def __init__(self, logger, regex, required=True):
        """Constructs an ExpectLog context manager.

        :param logger: Logger object (or name of logger) to watch.  Pass
            an empty string to watch the root logger.
        :param regex: Regular expression to match.  Any log entries on
            the specified logger that match this regex will be suppressed.
        :param required: If true, an exception will be raised if the end of
            the ``with`` statement is reached without matching any log entries.
        """
        if isinstance(logger, basestring_type):
            logger = logging.getLogger(logger)
        self.logger = logger
        self.regex = re.compile(regex)
        self.required = required
        self.matched = False
        self.logged_stack = False 
开发者ID:tp4a,项目名称:teleport,代码行数:19,代码来源:testing.py

示例6: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def __init__(self, name, default=None, type=basestring_type, help=None,
                 metavar=None, multiple=False, file_name=None, group_name=None,
                 callback=None):
        if default is None and multiple:
            default = []
        self.name = name
        self.type = type
        self.help = help
        self.metavar = metavar
        self.multiple = multiple
        self.file_name = file_name
        self.group_name = group_name
        self.callback = callback
        self.default = default
        self._value = _Option.UNSET 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:17,代码来源:options.py

示例7: test_utf8_logging

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def test_utf8_logging(self):
        with ignore_bytes_warning():
            self.logger.error(u("\u00e9").encode("utf8"))
        if issubclass(bytes, basestring_type):
            # on python 2, utf8 byte strings (and by extension ascii byte
            # strings) are passed through as-is.
            self.assertEqual(self.get_output(), utf8(u("\u00e9")))
        else:
            # on python 3, byte strings always get repr'd even if
            # they're ascii-only, so this degenerates into another
            # copy of test_bytes_logging.
            self.assertEqual(self.get_output(), utf8(repr(utf8(u("\u00e9"))))) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:14,代码来源:log_test.py

示例8: add_rules

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def add_rules(self, rules: _RuleList) -> None:
        """Appends new rules to the router.

        :arg rules: a list of Rule instances (or tuples of arguments, which are
            passed to Rule constructor).
        """
        for rule in rules:
            if isinstance(rule, (tuple, list)):
                assert len(rule) in (2, 3, 4)
                if isinstance(rule[0], basestring_type):
                    rule = Rule(PathMatches(rule[0]), *rule[1:])
                else:
                    rule = Rule(*rule)

            self.rules.append(self.process_rule(rule)) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:17,代码来源:routing.py

示例9: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def __init__(self, host_pattern: Union[str, Pattern]) -> None:
        if isinstance(host_pattern, basestring_type):
            if not host_pattern.endswith("$"):
                host_pattern += "$"
            self.host_pattern = re.compile(host_pattern)
        else:
            self.host_pattern = host_pattern 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:9,代码来源:routing.py

示例10: _define_options

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def _define_options(self):
        options = OptionParser()
        options.define("str", type=str)
        options.define("basestring", type=basestring_type)
        options.define("int", type=int)
        options.define("float", type=float)
        options.define("datetime", type=datetime.datetime)
        options.define("timedelta", type=datetime.timedelta)
        options.define("email", type=Email)
        options.define("list-of-int", type=int, multiple=True)
        return options 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:13,代码来源:options_test.py

示例11: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def __init__(self, name, default=None, type=basestring_type, help=None,
                 metavar=None, multiple=False, file_name=None, group_name=None,
                 callback=None):
        if default is None and multiple:
            default = []
        self.name = name
        self.type = type
        self.help = help
        self.metavar = metavar
        self.multiple = multiple
        self.file_name = file_name
        self.group_name = group_name
        self.callback = callback
        self.default = default
        self._value = None 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:17,代码来源:options.py

示例12: test_utf8_logging

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import basestring_type [as 别名]
def test_utf8_logging(self):
        self.logger.error(u("\u00e9").encode("utf8"))
        if issubclass(bytes_type, basestring_type):
            # on python 2, utf8 byte strings (and by extension ascii byte
            # strings) are passed through as-is.
            self.assertEqual(self.get_output(), utf8(u("\u00e9")))
        else:
            # on python 3, byte strings always get repr'd even if
            # they're ascii-only, so this degenerates into another
            # copy of test_bytes_logging.
            self.assertEqual(self.get_output(), utf8(repr(utf8(u("\u00e9"))))) 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:13,代码来源:log_test.py


注:本文中的tornado.util.basestring_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。