本文整理匯總了Python中symbol.decorators方法的典型用法代碼示例。如果您正苦於以下問題:Python symbol.decorators方法的具體用法?Python symbol.decorators怎麽用?Python symbol.decorators使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類symbol
的用法示例。
在下文中一共展示了symbol.decorators方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: decorators
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import decorators [as 別名]
def decorators(self, nodelist):
# decorators: decorator ([NEWLINE] decorator)* NEWLINE
items = []
for dec_nodelist in nodelist:
assert dec_nodelist[0] == symbol.decorator
items.append(self.decorator(dec_nodelist[1:]))
return Decorators(items)
示例2: decorated
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import decorators [as 別名]
def decorated(self, nodelist):
assert nodelist[0][0] == symbol.decorators
if nodelist[1][0] == symbol.funcdef:
n = [nodelist[0]] + list(nodelist[1][1:])
return self.funcdef(n)
elif nodelist[1][0] == symbol.classdef:
decorators = self.decorators(nodelist[0][1:])
cls = self.classdef(nodelist[1][1:])
cls.decorators = decorators
return cls
raise WalkerError()
示例3: funcdef
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import decorators [as 別名]
def funcdef(self, nodelist):
# -6 -5 -4 -3 -2 -1
# funcdef: [decorators] 'def' NAME parameters ':' suite
# parameters: '(' [varargslist] ')'
if len(nodelist) == 6:
assert nodelist[0][0] == symbol.decorators
decorators = self.decorators(nodelist[0][1:])
else:
assert len(nodelist) == 5
decorators = None
lineno = nodelist[-4][2]
name = nodelist[-4][1]
args = nodelist[-3][2]
if args[0] == symbol.varargslist:
names, defaults, flags = self.com_arglist(args[1:])
else:
names = defaults = ()
flags = 0
doc = self.get_docstring(nodelist[-1])
# code for function
code = self.com_node(nodelist[-1])
if doc is not None:
assert isinstance(code, Stmt)
assert isinstance(code.nodes[0], Discard)
del code.nodes[0]
return Function(decorators, name, names, defaults, flags, doc, code,
lineno=lineno)
示例4: _get_forbidden_symbols
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import decorators [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