本文整理匯總了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)