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


Python six.string_types方法代码示例

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


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

示例1: __str__

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def __str__(self):
        if self.req:
            s = str(self.req)
            if self.link:
                s += ' from %s' % self.link.url
        else:
            s = self.link.url if self.link else None
        if self.satisfied_by is not None:
            s += ' in %s' % display_path(self.satisfied_by.location)
        if self.comes_from:
            if isinstance(self.comes_from, six.string_types):
                comes_from = self.comes_from
            else:
                comes_from = self.comes_from.from_path()
            if comes_from:
                s += ' (from %s)' % comes_from
        return s 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:19,代码来源:req_install.py

示例2: get_default_values

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def get_default_values(self):
        """Overriding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work."""
        if not self.process_default_values:
            # Old, pre-Optik 1.5 behaviour.
            return optparse.Values(self.defaults)

        # Load the configuration, or error out in case of an error
        try:
            self.config.load()
        except ConfigurationError as err:
            self.exit(2, err.args[0])

        defaults = self._update_defaults(self.defaults.copy())  # ours
        for option in self._get_all_options():
            default = defaults.get(option.dest)
            if isinstance(default, string_types):
                opt_str = option.get_opt_string()
                defaults[option.dest] = option.check_value(opt_str, default)
        return optparse.Values(defaults) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:22,代码来源:baseparser.py

示例3: __str__

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def __str__(self):
        # type: () -> str
        if self.req:
            s = str(self.req)
            if self.link:
                s += ' from %s' % redact_password_from_url(self.link.url)
        elif self.link:
            s = redact_password_from_url(self.link.url)
        else:
            s = '<InstallRequirement>'
        if self.satisfied_by is not None:
            s += ' in %s' % display_path(self.satisfied_by.location)
        if self.comes_from:
            if isinstance(self.comes_from, six.string_types):
                comes_from = self.comes_from
            else:
                comes_from = self.comes_from.from_path()
            if comes_from:
                s += ' (from %s)' % comes_from
        return s 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:22,代码来源:req_install.py

示例4: convert

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def convert(self, value):
        """
        Convert values to an appropriate type. dicts, lists and tuples are
        replaced by their converting alternatives. Strings are checked to
        see if they have a conversion format and are converted if they do.
        """
        if not isinstance(value, ConvertingDict) and isinstance(value, dict):
            value = ConvertingDict(value)
            value.configurator = self
        elif not isinstance(value, ConvertingList) and isinstance(value, list):
            value = ConvertingList(value)
            value.configurator = self
        elif not isinstance(value, ConvertingTuple) and\
                 isinstance(value, tuple):
            value = ConvertingTuple(value)
            value.configurator = self
        elif isinstance(value, six.string_types):  # str for py3k
            m = self.CONVERT_PATTERN.match(value)
            if m:
                d = m.groupdict()
                prefix = d['prefix']
                converter = self.value_converters.get(prefix, None)
                if converter:
                    suffix = d['suffix']
                    converter = getattr(self, converter)
                    value = converter(suffix)
        return value 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:29,代码来源:dictconfig.py

示例5: get_distribution

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def get_distribution(dist):
    """Return a current distribution object for a Requirement or string"""
    if isinstance(dist, six.string_types):
        dist = Requirement.parse(dist)
    if isinstance(dist, Requirement):
        dist = get_provider(dist)
    if not isinstance(dist, Distribution):
        raise TypeError("Expected string, Requirement, or Distribution", dist)
    return dist 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,代码来源:__init__.py

示例6: yield_lines

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def yield_lines(strs):
    """Yield non-empty/non-comment lines of a string or sequence"""
    if isinstance(strs, six.string_types):
        for s in strs.splitlines():
            s = s.strip()
            # skip blank lines/comments
            if s and not s.startswith('#'):
                yield s
    else:
        for ss in strs:
            for s in yield_lines(ss):
                yield s 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:__init__.py

示例7: get_default_values

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def get_default_values(self):
        """Overriding to make updating the defaults after instantiation of
        the option parser possible, _update_defaults() does the dirty work."""
        if not self.process_default_values:
            # Old, pre-Optik 1.5 behaviour.
            return optparse.Values(self.defaults)

        defaults = self._update_defaults(self.defaults.copy())  # ours
        for option in self._get_all_options():
            default = defaults.get(option.dest)
            if isinstance(default, string_types):
                opt_str = option.get_opt_string()
                defaults[option.dest] = option.check_value(opt_str, default)
        return optparse.Values(defaults) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:16,代码来源:baseparser.py

示例8: yield_lines

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def yield_lines(strs):
    """Yield non-empty/non-comment lines of a string or sequence"""
    if isinstance(strs, six.string_types):
        for s in strs.splitlines():
            s = s.strip()
            # skip blank lines/comments
            if s and not s.startswith('#'):
                yield s
    else:
        for ss in strs:
            for s in yield_lines(ss):
                yield s

# whitespace and comment 
开发者ID:jpush,项目名称:jbox,代码行数:16,代码来源:__init__.py

示例9: is_text_or_none

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def is_text_or_none(string):
    """Wrapper around isinstance(string_types) or is None"""
    return string is None or isinstance(string, string_types) 
开发者ID:jpush,项目名称:jbox,代码行数:5,代码来源:_base.py

示例10: emptyTag

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def emptyTag(self, namespace, name, attrs, hasChildren=False):
        assert namespace is None or isinstance(namespace, string_types), type(namespace)
        assert isinstance(name, string_types), type(name)
        assert all((namespace is None or isinstance(namespace, string_types)) and
                   isinstance(name, string_types) and
                   isinstance(value, string_types)
                   for (namespace, name), value in attrs.items())

        yield {"type": "EmptyTag", "name": to_text(name, False),
               "namespace": to_text(namespace),
               "data": attrs}
        if hasChildren:
            yield self.error("Void element has children") 
开发者ID:jpush,项目名称:jbox,代码行数:15,代码来源:_base.py

示例11: endTag

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def endTag(self, namespace, name):
        assert namespace is None or isinstance(namespace, string_types), type(namespace)
        assert isinstance(name, string_types), type(namespace)

        return {"type": "EndTag",
                "name": to_text(name, False),
                "namespace": to_text(namespace),
                "data": {}} 
开发者ID:jpush,项目名称:jbox,代码行数:10,代码来源:_base.py

示例12: text

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def text(self, data):
        assert isinstance(data, string_types), type(data)

        data = to_text(data)
        middle = data.lstrip(spaceCharacters)
        left = data[:len(data) - len(middle)]
        if left:
            yield {"type": "SpaceCharacters", "data": left}
        data = middle
        middle = data.rstrip(spaceCharacters)
        right = data[len(middle):]
        if middle:
            yield {"type": "Characters", "data": middle}
        if right:
            yield {"type": "SpaceCharacters", "data": right} 
开发者ID:jpush,项目名称:jbox,代码行数:17,代码来源:_base.py

示例13: comment

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def comment(self, data):
        assert isinstance(data, string_types), type(data)

        return {"type": "Comment", "data": text_type(data)} 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:_base.py

示例14: entity

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def entity(self, name):
        assert isinstance(name, string_types), type(name)

        return {"type": "Entity", "name": text_type(name)} 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:_base.py

示例15: from_path

# 需要导入模块: from pip._vendor import six [as 别名]
# 或者: from pip._vendor.six import string_types [as 别名]
def from_path(self):
        if self.req is None:
            return None
        s = str(self.req)
        if self.comes_from:
            if isinstance(self.comes_from, six.string_types):
                comes_from = self.comes_from
            else:
                comes_from = self.comes_from.from_path()
            if comes_from:
                s += '->' + comes_from
        return s 
开发者ID:jpush,项目名称:jbox,代码行数:14,代码来源:req_install.py


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