Python symbol.import_as_name() Examples

The following are 26 code examples of symbol.import_as_name(). 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 symbol , or try the search function .
Example #1
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def Annotate(cls, symbol_type, children):
    if (symbol_type != symbol.dotted_as_name and
        symbol_type != symbol.import_as_name):
      return None
    return cls(symbol_type, children) 
Example #2
Source File: transformer.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1] 
Example #3
Source File: transformer.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1] 
Example #4
Source File: transformer.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1] 
Example #5
Source File: transformer.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1] 
Example #6
Source File: transformer.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1] 
Example #7
Source File: transformer.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1] 
Example #8
Source File: transformer.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1] 
Example #9
Source File: recipe-576404.py    From code with MIT License 5 votes vote down vote up
def _get_forbidden_symbols():
    """
    Returns a list of symbol codes representing statements that are *not*
    wanted in configuration files.
    """
    try:
        # Python 2.5:
        symlst = [symbol.break_stmt, symbol.classdef, symbol.continue_stmt,
                  symbol.decorator, symbol.decorators, symbol.eval_input,
                  symbol.except_clause, symbol.exec_stmt, symbol.flow_stmt,
                  symbol.for_stmt, symbol.fpdef, symbol.fplist, symbol.funcdef,
                  symbol.global_stmt, symbol.import_as_name, symbol.import_as_names,
                  symbol.import_from, symbol.import_name, symbol.import_stmt,
                  symbol.lambdef, symbol.old_lambdef, symbol.print_stmt,
                  symbol.raise_stmt, symbol.try_stmt, symbol.while_stmt,
                  symbol.with_stmt, symbol.with_var, symbol.yield_stmt,
                  symbol.yield_expr]
        
    except AttributeError:
        # Python 2.4:        
        symlst = [symbol.break_stmt, symbol.classdef, symbol.continue_stmt,
                  symbol.decorator, symbol.decorators, symbol.eval_input,
                  symbol.except_clause, symbol.exec_stmt, symbol.flow_stmt,
                  symbol.for_stmt, symbol.fpdef, symbol.fplist, symbol.funcdef,
                  symbol.global_stmt, symbol.import_as_name, symbol.import_as_names,
                  symbol.import_from, symbol.import_name, symbol.import_stmt,
                  symbol.lambdef, symbol.print_stmt, symbol.raise_stmt,
                  symbol.try_stmt, symbol.while_stmt]
    
    return symlst 
Example #10
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def alias(self):
    import_as_name = self._import_as_name
    if import_as_name:
      return import_as_name.alias
    else:
      return None 
Example #11
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def module(self, value):
    if keyword.iskeyword(value):
      raise ValueError('%s is a reserved keyword.' % value)

    import_as_name = self._import_as_name
    if value == '*':
      # TODO: Implement this.
      raise NotImplementedError()
    else:
      if import_as_name:
        import_as_name.name = value
      else:
        # TODO: Implement this.
        raise NotImplementedError() 
Example #12
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def module(self):
    import_as_name = self._import_as_name
    if import_as_name:
      return import_as_name.name
    else:
      return '*' 
Example #13
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def values(self):
    try:
      import_as_names = self.FindChild(symbol.import_as_names)
    except ValueError:
      return (('*', None),)

    return tuple((import_as_name.name, import_as_name.alias)
                 for import_as_name in import_as_names.children[::2]) 
Example #14
Source File: transformer.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1] 
Example #15
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def alias(self):
    import_as_name = self._import_as_name
    if import_as_name:
      return import_as_name.alias
    else:
      return None 
Example #16
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def module(self, value):
    if keyword.iskeyword(value):
      raise ValueError('%s is a reserved keyword.' % value)

    import_as_name = self._import_as_name
    if value == '*':
      # TODO: Implement this.
      raise NotImplementedError()
    else:
      if import_as_name:
        import_as_name.name = value
      else:
        # TODO: Implement this.
        raise NotImplementedError() 
Example #17
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def module(self):
    import_as_name = self._import_as_name
    if import_as_name:
      return import_as_name.name
    else:
      return '*' 
Example #18
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def values(self):
    try:
      import_as_names = self.FindChild(symbol.import_as_names)
    except ValueError:
      return (('*', None),)

    return tuple((import_as_name.name, import_as_name.alias)
                 for import_as_name in import_as_names.children[::2]) 
Example #19
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def Annotate(cls, symbol_type, children):
    if (symbol_type != symbol.dotted_as_name and
        symbol_type != symbol.import_as_name):
      return None
    return cls(symbol_type, children) 
Example #20
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def alias(self):
    import_as_name = self._import_as_name
    if import_as_name:
      return import_as_name.alias
    else:
      return None 
Example #21
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def module(self, value):
    if keyword.iskeyword(value):
      raise ValueError('%s is a reserved keyword.' % value)

    import_as_name = self._import_as_name
    if value == '*':
      # TODO: Implement this.
      raise NotImplementedError()
    else:
      if import_as_name:
        import_as_name.name = value
      else:
        # TODO: Implement this.
        raise NotImplementedError() 
Example #22
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def module(self):
    import_as_name = self._import_as_name
    if import_as_name:
      return import_as_name.name
    else:
      return '*' 
Example #23
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def values(self):
    try:
      import_as_names = self.FindChild(symbol.import_as_names)
    except ValueError:
      return (('*', None),)

    return tuple((import_as_name.name, import_as_name.alias)
                 for import_as_name in import_as_names.children[::2]) 
Example #24
Source File: import_statement.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def Annotate(cls, symbol_type, children):
    if (symbol_type != symbol.dotted_as_name and
        symbol_type != symbol.import_as_name):
      return None
    return cls(symbol_type, children) 
Example #25
Source File: transformer.py    From oss-ftp with MIT License 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1] 
Example #26
Source File: transformer.py    From BinderFilter with MIT License 5 votes vote down vote up
def com_import_as_name(self, node):
        assert node[0] == symbol.import_as_name
        node = node[1:]
        assert node[0][0] == token.NAME
        if len(node) == 1:
            return node[0][1], None
        assert node[1][1] == 'as', node
        assert node[2][0] == token.NAME
        return node[0][1], node[2][1]