Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(32)  |  Call(16)  |  Derive(0)  |  Import(16)
return true if the two given statements are mutually exclusive

`exceptions` may be a list of exception names. If specified, discard If
branches and check one of the statement is in an exception handler catching
one of the given exceptions.

algorithm :
 1) index stmt1's parents
 2) climb among stmt2's parents until we find a common parent
 3) if the common parent is a If or TryExcept statement, look if nodes are(more...)

        def are_exclusive(stmt1, stmt2, exceptions=None):
    """return true if the two given statements are mutually exclusive

    `exceptions` may be a list of exception names. If specified, discard If
    branches and check one of the statement is in an exception handler catching
    one of the given exceptions.

    algorithm :
     1) index stmt1's parents
     2) climb among stmt2's parents until we find a common parent
     3) if the common parent is a If or TryExcept statement, look if nodes are
        in exclusive branches
    """
    # index stmt1's parents
    stmt1_parents = {}
    children = {}
    node = stmt1.parent
    previous = stmt1
    while node:
        stmt1_parents[node] = 1
        children[node] = previous
        previous = node
        node = node.parent
    # climb among stmt2's parents until we find a common parent
    node = stmt2.parent
    previous = stmt2
    while node:
        if node in stmt1_parents:
            # if the common parent is a If or TryExcept statement, look if
            # nodes are in exclusive branches
            if isinstance(node, If) and exceptions is None:
                if (node.locate_child(previous)[1]
                    is not node.locate_child(children[node])[1]):
                    return True
            elif isinstance(node, TryExcept):
                c2attr, c2node = node.locate_child(previous)
                c1attr, c1node = node.locate_child(children[node])
                if c1node is not c2node:
                    if ((c2attr == 'body' and c1attr == 'handlers' and children[node].catch(exceptions)) or
                        (c2attr == 'handlers' and c1attr == 'body' and previous.catch(exceptions)) or
                        (c2attr == 'handlers' and c1attr == 'orelse') or
                        (c2attr == 'orelse' and c1attr == 'handlers')):
                        return True
                elif c2attr == 'handlers' and c1attr == 'handlers':
                    return previous is not children[node]
            return False
        previous = node
        node = node.parent
    return False
        


src/p/y/pylama_pylint-0.1.6/pylama_pylint/pylint/checkers/variables.py   pylama_pylint(Download)
 
import astroid
from astroid import are_exclusive, builtin_lookup, AstroidBuildingException
 
from pylint.interfaces import IAstroidChecker
                    and stmt.fromlineno <= defstmt.fromlineno
                    and not is_defined_before(node)
                    and not are_exclusive(stmt, defstmt, ('NameError', 'Exception', 'BaseException'))):
                    if defstmt is stmt and isinstance(node, (astroid.DelName,
                                                             astroid.AssName)):

src/p/y/pylama_pylint-0.1.6/pylint/checkers/variables.py   pylama_pylint(Download)
 
import astroid
from astroid import are_exclusive, builtin_lookup, AstroidBuildingException
 
from pylint.interfaces import IAstroidChecker
                    and stmt.fromlineno <= defstmt.fromlineno
                    and not is_defined_before(node)
                    and not are_exclusive(stmt, defstmt, ('NameError', 'Exception', 'BaseException'))):
                    if defstmt is stmt and isinstance(node, (astroid.DelName,
                                                             astroid.AssName)):

src/p/y/Python-mode-klen-HEAD/pymode/libs/pylama/lint/pylama_pylint/pylint/checkers/variables.py   Python-mode-klen(Download)
 
from .. import astroid
from ..astroid import are_exclusive, builtin_lookup, AstroidBuildingException
 
from ..interfaces import IAstroidChecker
                    and stmt.fromlineno <= defstmt.fromlineno
                    and not is_defined_before(node)
                    and not are_exclusive(stmt, defstmt, ('NameError', 'Exception', 'BaseException'))):
                    if defstmt is stmt and isinstance(node, (astroid.DelName,
                                                             astroid.AssName)):

src/p/y/pylint-1.2.1/checkers/variables.py   pylint(Download)
 
import astroid
from astroid import are_exclusive, builtin_lookup, AstroidBuildingException
 
from logilab.common.modutils import file_from_modpath
                    and stmt.fromlineno <= defstmt.fromlineno
                    and not is_defined_before(node)
                    and not are_exclusive(stmt, defstmt, ('NameError', 'Exception', 'BaseException'))):
                    if defstmt is stmt and isinstance(node, (astroid.DelName,
                                                             astroid.AssName)):

src/p/y/pylama_pylint-0.1.6/pylama_pylint/pylint/checkers/classes.py   pylama_pylint(Download)
import sys
import astroid
from astroid import YES, Instance, are_exclusive, AssAttr
from astroid.bases import Generator
 
                    for _node in nodes:
                        if _node.frame() is frame and _node.fromlineno < lno \
                           and not are_exclusive(_node.statement(), defstmt, ('AttributeError', 'Exception', 'BaseException')):
                            self.add_message('E0203', node=_node,
                                             args=(attr, lno))

src/p/y/pylama_pylint-0.1.6/pylint/checkers/classes.py   pylama_pylint(Download)
import sys
import astroid
from astroid import YES, Instance, are_exclusive, AssAttr
from astroid.bases import Generator
 
                    for _node in nodes:
                        if _node.frame() is frame and _node.fromlineno < lno \
                           and not are_exclusive(_node.statement(), defstmt, ('AttributeError', 'Exception', 'BaseException')):
                            self.add_message('E0203', node=_node,
                                             args=(attr, lno))

src/p/y/Python-mode-klen-HEAD/pymode/libs/pylama/lint/pylama_pylint/pylint/checkers/classes.py   Python-mode-klen(Download)
 
from .. import astroid
from ..astroid import YES, Instance, are_exclusive, AssAttr
 
from ..interfaces import IAstroidChecker
                    for _node in nodes:
                        if _node.frame() is frame and _node.fromlineno < lno \
                           and not are_exclusive(_node.statement(), defstmt, ('AttributeError', 'Exception', 'BaseException')):
                            self.add_message('E0203', node=_node,
                                             args=(attr, lno))

src/p/y/pylint-1.2.1/checkers/classes.py   pylint(Download)
 
import astroid
from astroid import YES, Instance, are_exclusive, AssAttr
from astroid.bases import Generator
 
                    for _node in nodes:
                        if _node.frame() is frame and _node.fromlineno < lno \
                           and not are_exclusive(_node.statement(), defstmt, ('AttributeError', 'Exception', 'BaseException')):
                            self.add_message('access-member-before-definition',
                                             node=_node, args=(attr, lno))

src/p/y/pylama_pylint-0.1.6/pylama_pylint/pylint/checkers/base.py   pylama_pylint(Download)
import astroid
from logilab.common.ureports import Table
from astroid import are_exclusive
import astroid.bases
 
    def _check_redefinition(self, redeftype, node):
        """check for redefinition of a function / method / class name"""
        defined_self = node.parent.frame()[node.name]
        if defined_self is not node and not are_exclusive(node, defined_self):
            self.add_message('function-redefined', node=node,

src/p/y/pylint-1.2.1/checkers/base.py   pylint(Download)
import astroid
from logilab.common.ureports import Table
from astroid import are_exclusive, InferenceError
import astroid.bases
 
    def _check_redefinition(self, redeftype, node):
        """check for redefinition of a function / method / class name"""
        defined_self = node.parent.frame()[node.name]
        if defined_self is not node and not are_exclusive(node, defined_self):
            self.add_message('function-redefined', node=node,

  1 | 2  Next