本文整理汇总了Python中codeintel2.manager.Manager._register_modules方法的典型用法代码示例。如果您正苦于以下问题:Python Manager._register_modules方法的具体用法?Python Manager._register_modules怎么用?Python Manager._register_modules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类codeintel2.manager.Manager
的用法示例。
在下文中一共展示了Manager._register_modules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Driver
# 需要导入模块: from codeintel2.manager import Manager [as 别名]
# 或者: from codeintel2.manager.Manager import _register_modules [as 别名]
#.........这里部分代码省略.........
def do_abort(self, request):
try:
req_id = request["id"]
with self.queue_cv:
for item in self.queue:
if item.get("req_id") == req_id:
self.queue.remove(item)
self.send(request=request)
break
else:
self.abort = req_id
if self.active_request and self.active_request.id == req_id:
# need to wait a bit...
self.send(request=request)
else:
self.fail(request=request,
message="Request %s not found" % (req_id,))
except RequestFailure as e:
self.fail(request=request, **e.kwargs)
except Exception as e:
log.exception(e.message)
self.exception(request=request, message=e.message)
def do_add_dirs(self, request):
catalog_dirs = request.get("catalog-dirs", None)
if catalog_dirs is not None:
self.mgr.db.catalog_dirs.extend(catalog_dirs)
catalog_dirs = self.mgr.db.catalog_dirs
lexer_dirs = request.get("lexer-dirs", [])
codeintel2.udl.UDLLexer.add_extra_lexer_dirs(lexer_dirs)
module_dirs = request.get("module-dirs", [])
if module_dirs:
self.mgr._register_modules(module_dirs)
if catalog_dirs is not None:
self.mgr.db.get_catalogs_zone().catalog_dirs = catalog_dirs
self.send(request=request)
def do_load_extension(self, request):
"""Load an extension that, for example, might provide additional
command handlers"""
name = request.get("module-name", None)
if not name:
raise RequestFailure(msg="load-extension requires a module-name")
path = request.get("module-path", None)
names = name.split(".")
if len(names) > 1:
# It's inside a package - go look for the package(s).
for package_name in names[:-1]:
iinfo = imp.find_module(package_name, [path] if path else None)
if not iinfo:
raise RequestFailure(msg="load-extension could not find "
"package %r for given name %r"
% (package_name, name))
path = iinfo[1]
name = names[-1]
iinfo = imp.find_module(name, [path] if path else None)
try:
module = imp.load_module(name, *iinfo)
finally:
if iinfo and iinfo[0]:
iinfo[0].close()
callback = getattr(module, "registerExtension", None)
if not callback:
raise RequestFailure(msg="load-extension module %s should "
"have a 'registerExtension' method "
示例2: Driver
# 需要导入模块: from codeintel2.manager import Manager [as 别名]
# 或者: from codeintel2.manager.Manager import _register_modules [as 别名]
#.........这里部分代码省略.........
return buf
def do_abort(self, request):
try:
req_id = request["id"]
with self.queue_cv:
for item in self.queue:
if queue.get("req_id") == req_id:
self.queue.remove(queue)
self.send(request=request)
break
else:
self.abort = req_id
if self.active_request and self.active_request.id == req_id:
# need to wait a bit...
self.send(request=request)
else:
self.fail(request=request,
message="Request %s not found" % (req_id,))
except RequestFailure as e:
self.fail(request=request, *e.args, **e.kwargs)
except Exception as e:
log.exception(e.message)
self.exception(request=request, message=e.message)
def do_add_dirs(self, request):
catalog_dirs = request.get("catalog-dirs", None)
if catalog_dirs is not None:
self.mgr.db.catalog_dirs.extend(catalog_dirs)
lexer_dirs = request.get("lexer-dirs", [])
codeintel2.udl.UDLLexer.add_extra_lexer_dirs(lexer_dirs)
module_dirs = request.get("module-dirs", [])
if module_dirs:
self.mgr._register_modules(module_dirs)
if catalog_dirs is not None:
self.mgr.db.get_catalogs_zone().update()
def do_load_extension(self, request):
"""Load an extension that, for example, might provide additional
command handlers"""
path = request.get("module-path", None)
if not path:
raise RequestFailure(msg="load-extension requires a module-path")
name = request.get("module-name", None)
if not name:
raise RequestFailure(msg="load-extension requires a module-name")
iinfo = imp.find_module(name, [path])
try:
module = imp.load_module(name, *iinfo)
finally:
if iinfo and iinfo[0]:
iinfo[0].close()
callback = getattr(module, "registerExtension", None)
if not callback:
raise RequestFailure(msg="load-extension module %s should "
"have a 'registerExtension' method "
"taking no arguments" % (name,))
callback()
self.send() # success, finally
def do_quit(self, request):
self.quit = True
self.send(command="quit")
def report_error(self, message):
self.send(request=None,