本文整理汇总了Python中parser.Parser方法的典型用法代码示例。如果您正苦于以下问题:Python parser.Parser方法的具体用法?Python parser.Parser怎么用?Python parser.Parser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser
的用法示例。
在下文中一共展示了parser.Parser方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import parser [as 别名]
# 或者: from parser import Parser [as 别名]
def __init__(self):
if not os.path.exists(common.Paths.pluginDataDir):
os.makedirs(common.Paths.pluginDataDir, 0777)
self.favouritesManager = FavouritesManager(common.Paths.favouritesFolder)
self.customModulesManager = CustomModulesManager(common.Paths.customModulesDir, common.Paths.customModulesRepo)
if not os.path.exists(common.Paths.customModulesDir):
os.makedirs(common.Paths.customModulesDir, 0777)
self.parser = Parser()
self.currentlist = None
self.addon = None
common.log('SportsDevil initialized')
示例2: __init__
# 需要导入模块: import parser [as 别名]
# 或者: from parser import Parser [as 别名]
def __init__(self, host="0.0.0.0", port=8123):
self.online = []
self.inv = {}
self.redis = redis.Redis(decode_responses=True)
self.parser = Parser()
self.conflicts = self.parser.parse_conflicts()
self.achievements = self.parser.parse_achievements()
self.trophies = self.parser.parse_trophies()
self.game_items = self.parser.parse_game_items()
self.appearance = self.parser.parse_appearance()
self.modules = {}
for item in modules:
module = importlib.import_module(f"modules.{item}")
class_ = getattr(module, module.class_name)
self.modules[class_.prefix] = class_(self)
self.revision = get_git_revision_short_hash()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.sock.bind((host, port))
示例3: __init__
# 需要导入模块: import parser [as 别名]
# 或者: from parser import Parser [as 别名]
def __init__(self):
self.parser = Parser()
示例4: __init__
# 需要导入模块: import parser [as 别名]
# 或者: from parser import Parser [as 别名]
def __init__(self, database, dir_path, debug=False):
self._parser = Parser()
self._wrapper = Wrapper()
self._writer = Writer(database)
self._sitemap_generator = SitemapGenerator(database)
self._feeds_generator = FeedsGenerator(database)
self._debug = debug
self._dir_path = dir_path
self._database = database
self._file_path = ""
示例5: makeParser
# 需要导入模块: import parser [as 别名]
# 或者: from parser import Parser [as 别名]
def makeParser(self, text):
from parser import Lexer, Parser
lexer = Lexer(text)
parser = Parser(lexer)
return parser
示例6: assertParsed
# 需要导入模块: import parser [as 别名]
# 或者: from parser import Parser [as 别名]
def assertParsed(self, s, declstr):
"""Helper for testing parsed code.
Parses s into an AST node and asserts that its string representation
is equal to declstr.
"""
p = Parser()
node = p.parse_decl(s)
self.assertEqual(str(node), declstr)
示例7: test_parse_multiple
# 需要导入模块: import parser [as 别名]
# 或者: from parser import Parser [as 别名]
def test_parse_multiple(self):
p = Parser()
n1 = p.parse_decl('foo x = 10')
self.assertEqual(str(n1), 'Decl(foo, Lambda([x], 10))')
n2 = p.parse_decl('foo y = true')
self.assertEqual(str(n2), 'Decl(foo, Lambda([y], true))')
示例8: test_decl
# 需要导入模块: import parser [as 别名]
# 或者: from parser import Parser [as 别名]
def test_decl(self):
p = parser.Parser()
e = p.parse_decl('foo f x = f(3) - f(x)')
assign_typenames(e.expr)
self.assertEqual(str(e.expr.expr.left.func._type), 't1')
self.assertEqual(str(e.expr.expr.right.func._type), 't1')
self.assertEqual(str(e.expr.expr.right.args[0]._type), 't2')
self.assertEqual(str(e.expr.expr._type), 't3')
self.assertEqual(str(e.expr.expr.left._type), 't4')
self.assertEqual(str(e.expr.expr.right._type), 't5')
示例9: assertInferredType
# 需要导入模块: import parser [as 别名]
# 或者: from parser import Parser [as 别名]
def assertInferredType(self, decl, ty):
"""Assert that the type of the declaration is inferred to ty."""
p = parser.Parser()
e = p.parse_decl(decl)
assign_typenames(e.expr)
equations = []
generate_equations(e.expr, equations)
unifier = unify_all_equations(equations)
inferred = get_expression_type(e.expr, unifier, rename_types=True)
self.assertEqual(str(inferred), ty)