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


Python symbol.comparison方法代码示例

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


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

示例1: comparison

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import comparison [as 别名]
def comparison(cls, nodelist):
        if len(nodelist) > 4:
            msg = "Chained comparison not allowed in environment markers"
            raise SyntaxError(msg)
        comp = nodelist[2][1]
        cop = comp[1]
        if comp[0] == token.NAME:
            if len(nodelist[2]) == 3:
                if cop == 'not':
                    cop = 'not in'
                else:
                    cop = 'is not'
        try:
            cop = cls.get_op(cop)
        except KeyError:
            msg = repr(cop) + " operator not allowed in environment markers"
            raise SyntaxError(msg)
        return cop(cls.evaluate(nodelist[1]), cls.evaluate(nodelist[3])) 
开发者ID:jpush,项目名称:jbox,代码行数:20,代码来源:__init__.py

示例2: get_op

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import comparison [as 别名]
def get_op(cls, op):
        ops = {
            symbol.test: cls.test,
            symbol.and_test: cls.and_test,
            symbol.atom: cls.atom,
            symbol.comparison: cls.comparison,
            'not in': lambda x, y: x not in y,
            'in': lambda x, y: x in y,
            '==': operator.eq,
            '!=': operator.ne,
            '<':  operator.lt,
            '>':  operator.gt,
            '<=': operator.le,
            '>=': operator.ge,
        }
        if hasattr(symbol, 'or_test'):
            ops[symbol.or_test] = cls.test
        return ops[op] 
开发者ID:jpush,项目名称:jbox,代码行数:20,代码来源:__init__.py

示例3: comparison

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import comparison [as 别名]
def comparison(cls, nodelist):
        if len(nodelist)>4:
            raise SyntaxError("Chained comparison not allowed in environment markers")
        comp = nodelist[2][1]
        cop = comp[1]
        if comp[0] == token.NAME:
            if len(nodelist[2]) == 3:
                if cop == 'not':
                    cop = 'not in'
                else:
                    cop = 'is not'
        try:
            cop = cls.get_op(cop)
        except KeyError:
            raise SyntaxError(repr(cop)+" operator not allowed in environment markers")
        return cop(cls.evaluate(nodelist[1]), cls.evaluate(nodelist[3])) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:18,代码来源:pkg_resources.py

示例4: __getitem__

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import comparison [as 别名]
def __getitem__(self, project_name):
        """Return a newest-to-oldest list of distributions for `project_name`

        Uses case-insensitive `project_name` comparison, assuming all the
        project's distributions use their project's name converted to all
        lowercase as their key.

        """
        distribution_key = project_name.lower()
        return self._distmap.get(distribution_key, []) 
开发者ID:jpush,项目名称:jbox,代码行数:12,代码来源:__init__.py

示例5: normalize_path

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import comparison [as 别名]
def normalize_path(filename):
    """Normalize a file/dir name for comparison purposes"""
    return os.path.normcase(os.path.realpath(filename)) 
开发者ID:jpush,项目名称:jbox,代码行数:5,代码来源:__init__.py

示例6: get_op

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import comparison [as 别名]
def get_op(cls, op):
        ops = {
            symbol.test: cls.test,
            symbol.and_test: cls.and_test,
            symbol.atom: cls.atom,
            symbol.comparison: cls.comparison,
            'not in': lambda x, y: x not in y,
            'in': lambda x, y: x in y,
            '==': operator.eq,
            '!=': operator.ne,
        }
        if hasattr(symbol, 'or_test'):
            ops[symbol.or_test] = cls.test
        return ops[op] 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:16,代码来源:pkg_resources.py

示例7: _parse_version_parts

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import comparison [as 别名]
def _parse_version_parts(s):
    for part in component_re.split(s):
        part = replace(part, part)
        if not part or part=='.':
            continue
        if part[:1] in '0123456789':
            # pad for numeric comparison
            yield part.zfill(8)
        else:
            yield '*'+part

    # ensure that alpha/beta/candidate are before final
    yield '*final' 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:15,代码来源:pkg_resources.py

示例8: not_test

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import comparison [as 别名]
def not_test(self, nodelist):
        # 'not' not_test | comparison
        result = self.com_node(nodelist[-1])
        if len(nodelist) == 2:
            return Not(result, lineno=nodelist[0][2])
        return result 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:transformer.py

示例9: comparison

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import comparison [as 别名]
def comparison(self, nodelist):
        # comparison: expr (comp_op expr)*
        node = self.com_node(nodelist[0])
        if len(nodelist) == 1:
            return node

        results = []
        for i in range(2, len(nodelist), 2):
            nl = nodelist[i-1]

            # comp_op: '<' | '>' | '=' | '>=' | '<=' | '<>' | '!=' | '=='
            #          | 'in' | 'not' 'in' | 'is' | 'is' 'not'
            n = nl[1]
            if n[0] == token.NAME:
                type = n[1]
                if len(nl) == 3:
                    if type == 'not':
                        type = 'not in'
                    else:
                        type = 'is not'
            else:
                type = _cmp_types[n[0]]

            lineno = nl[1][2]
            results.append((type, self.com_node(nodelist[i])))

        # we need a special "compare" node so that we can distinguish
        #   3 < x < 5   from    (3 < x) < 5
        # the two have very different semantics and results (note that the
        # latter form is always true)

        return Compare(node, results, lineno=lineno) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:34,代码来源:transformer.py


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