本文整理匯總了Python中compiler.parseFile方法的典型用法代碼示例。如果您正苦於以下問題:Python compiler.parseFile方法的具體用法?Python compiler.parseFile怎麽用?Python compiler.parseFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類compiler
的用法示例。
在下文中一共展示了compiler.parseFile方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: installed_plugins
# 需要導入模塊: import compiler [as 別名]
# 或者: from compiler import parseFile [as 別名]
def installed_plugins(self):
"""List all plugins installed."""
from os import listdir
from fnmatch import fnmatch
import compiler
import inspect
files = listdir('Plugins')
try:
files.remove('mount.py')
files.remove('template.py')
except ValueError:
pass
plugins = {}
for element in files:
if fnmatch(element, '*.py') and not fnmatch(element, '_*'):
plug_doc = compiler.parseFile('Plugins/' + element).doc
plug_doc = inspect.cleandoc(plug_doc)
plugins[element[:-3]] = plug_doc # Remove .py)
return plugins
示例2: parseModule
# 需要導入模塊: import compiler [as 別名]
# 或者: from compiler import parseFile [as 別名]
def parseModule(self, module_name, file_name):
importing = False
if file_name not in self.parse_cache:
importing = True
mod = compiler.parseFile(file_name)
self.parse_cache[file_name] = mod
else:
mod = self.parse_cache[file_name]
override = False
platform_file_name = self.generatePlatformFilename(file_name)
if self.platform and os.path.isfile(platform_file_name):
mod = copy.deepcopy(mod)
mod_override = compiler.parseFile(platform_file_name)
self.merge(mod, mod_override)
override = True
if self.verbose:
if override:
print("Importing %s (Platform %s)" % (module_name, self.platform))
elif importing:
print("Importing %s" % (module_name))
return mod, override
示例3: check_i18n
# 需要導入模塊: import compiler [as 別名]
# 或者: from compiler import parseFile [as 別名]
def check_i18n(input_file, i18n_msg_predicates, msg_format_checkers, debug):
input_mod = compiler.parseFile(input_file)
v = compiler.visitor.walk(input_mod,
Visitor(input_file,
i18n_msg_predicates,
msg_format_checkers,
debug),
ASTWalker())
return v.error
示例4: testLineNo
# 需要導入模塊: import compiler [as 別名]
# 或者: from compiler import parseFile [as 別名]
def testLineNo(self):
# Test that all nodes except Module have a correct lineno attribute.
filename = __file__
if filename.endswith((".pyc", ".pyo")):
filename = filename[:-1]
tree = compiler.parseFile(filename)
self.check_lineno(tree)
示例5: translate
# 需要導入模塊: import compiler [as 別名]
# 或者: from compiler import parseFile [as 別名]
def translate(file_name, module_name, debug=False):
f = open(file_name, "r")
src = f.read()
f.close()
output = cStringIO()
mod = compiler.parseFile(file_name)
Translator(module_name, module_name, module_name, src, debug, mod, output)
return output.getvalue()