Python lib2to3.pytree.Base() Examples

The following are 17 code examples of lib2to3.pytree.Base(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module lib2to3.pytree , or try the search function .
Example #1
Source File: test_pytree.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #2
Source File: test_pytree.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #3
Source File: test_pytree.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #4
Source File: test_pytree.py    From android_universal with MIT License 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #5
Source File: test_pytree.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #6
Source File: test_pytree.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #7
Source File: test_pytree.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #8
Source File: test_pytree.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #9
Source File: test_pytree.py    From datafari with Apache License 2.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #10
Source File: test_pytree.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #11
Source File: test_pytree.py    From Imogen with MIT License 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #12
Source File: test_pytree.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #13
Source File: test_pytree.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #14
Source File: test_pytree.py    From Computable with MIT License 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #15
Source File: test_pytree.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #16
Source File: test_pytree.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def test_instantiate_base(self):
        if __debug__:
            # Test that instantiating Base() raises an AssertionError
            self.assertRaises(AssertionError, pytree.Base) 
Example #17
Source File: fix_annotate_json.py    From pyannotate with Apache License 2.0 4 votes vote down vote up
def count_args(node, results):
    # type: (Node, Dict[str, Base]) -> Tuple[int, bool, bool, bool]
    """Count arguments and check for self and *args, **kwds.

    Return (selfish, count, star, starstar) where:
    - count is total number of args (including *args, **kwds)
    - selfish is True if the initial arg is named 'self' or 'cls'
    - star is True iff *args is found
    - starstar is True iff **kwds is found
    """
    count = 0
    selfish = False
    star = False
    starstar = False
    args = results.get('args')
    if isinstance(args, Node):
        children = args.children
    elif isinstance(args, Leaf):
        children = [args]
    else:
        children = []
    # Interpret children according to the following grammar:
    # (('*'|'**')? NAME ['=' expr] ','?)*
    skip = False
    previous_token_is_star = False
    for child in children:
        if skip:
            skip = False
        elif isinstance(child, Leaf):
            # A single '*' indicates the rest of the arguments are keyword only
            # and shouldn't be counted as a `*`.
            if child.type == token.STAR:
                previous_token_is_star = True
            elif child.type == token.DOUBLESTAR:
                starstar = True
            elif child.type == token.NAME:
                if count == 0:
                    if child.value in ('self', 'cls'):
                        selfish = True
                count += 1
                if previous_token_is_star:
                    star = True
            elif child.type == token.EQUAL:
                skip = True
            if child.type != token.STAR:
                previous_token_is_star = False
    return count, selfish, star, starstar