本文整理汇总了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()