本文整理匯總了Python中symbol.import_as_names方法的典型用法代碼示例。如果您正苦於以下問題:Python symbol.import_as_names方法的具體用法?Python symbol.import_as_names怎麽用?Python symbol.import_as_names使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類symbol
的用法示例。
在下文中一共展示了symbol.import_as_names方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: import_from
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import import_as_names [as 別名]
def import_from(self, nodelist):
# import_from: 'from' ('.'* dotted_name | '.') 'import' ('*' |
# '(' import_as_names ')' | import_as_names)
assert nodelist[0][1] == 'from'
idx = 1
while nodelist[idx][1] == '.':
idx += 1
level = idx - 1
if nodelist[idx][0] == symbol.dotted_name:
fromname = self.com_dotted_name(nodelist[idx])
idx += 1
else:
fromname = ""
assert nodelist[idx][1] == 'import'
if nodelist[idx + 1][0] == token.STAR:
return From(fromname, [('*', None)], level,
lineno=nodelist[0][2])
else:
node = nodelist[idx + 1 + (nodelist[idx + 1][0] == token.LPAR)]
return From(fromname, self.com_import_as_names(node), level,
lineno=nodelist[0][2])
示例2: com_import_as_names
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import import_as_names [as 別名]
def com_import_as_names(self, node):
assert node[0] == symbol.import_as_names
node = node[1:]
names = [self.com_import_as_name(node[0])]
for i in range(2, len(node), 2):
names.append(self.com_import_as_name(node[i]))
return names
示例3: values
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import import_as_names [as 別名]
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])
示例4: _import_as_name
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import import_as_names [as 別名]
def _import_as_name(self):
try:
import_as_names = self.FindChild(symbol.import_as_names)
except ValueError:
return None
if len(import_as_names.children) != 1:
raise NotImplementedError(
'This method only works if the statement has one import.')
return import_as_names.children[0]
示例5: _get_forbidden_symbols
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import import_as_names [as 別名]
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