本文整理汇总了Python中sphinx.util.import_object函数的典型用法代码示例。如果您正苦于以下问题:Python import_object函数的具体用法?Python import_object怎么用?Python import_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了import_object函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_supported_format
def get_supported_format(suffix):
parser_class = app.config.source_parsers.get(suffix)
if parser_class is None:
return ('restructuredtext',)
if isinstance(parser_class, string_types):
parser_class = import_object(parser_class, 'source parser')
return parser_class.supported
示例2: __init__
def __init__(self, module_path, base_module=None):
self.module = import_object(module_path)
self.base_module = base_module or self.module.__name__
self.module_classes = set()
self.inheritances = []
self._populate_tree()
示例3: get_supported_format
def get_supported_format(suffix):
# type: (unicode) -> Tuple[unicode]
parser_class = app.registry.get_source_parsers().get(suffix)
if parser_class is None:
return ('restructuredtext',)
if isinstance(parser_class, string_types):
parser_class = import_object(parser_class, 'source parser') # type: ignore
return parser_class.supported
示例4: get_parser_type
def get_parser_type(source_path):
# type: (unicode) -> Tuple[unicode]
for suffix, parser_class in iteritems(self.app.registry.get_source_parsers()):
if source_path.endswith(suffix):
if isinstance(parser_class, string_types):
parser_class = import_object(parser_class, 'source parser') # type: ignore # NOQA
return parser_class.supported
return ('restructuredtext',)
示例5: get_supported_format
def get_supported_format(suffix):
# type: (str) -> Tuple[str, ...]
parser_class = app.registry.get_source_parsers().get(suffix)
if parser_class is None:
return ('restructuredtext',)
if isinstance(parser_class, str):
parser_class = import_object(parser_class, 'source parser')
return parser_class.supported
示例6: get_parser_type
def get_parser_type(source_path):
for suffix in self.env.config.source_parsers:
if source_path.endswith(suffix):
parser_class = self.env.config.source_parsers[suffix]
if isinstance(parser_class, string_types):
parser_class = import_object(parser_class, 'source parser')
return parser_class.supported
else:
return ('restructuredtext',)
示例7: create_template_bridge
def create_template_bridge(self):
# type: () -> None
"""Return the template bridge configured."""
if self.config.template_bridge:
self.templates = import_object(self.config.template_bridge,
'template_bridge setting')()
else:
from sphinx.jinja2glue import BuiltinTemplateLoader
self.templates = BuiltinTemplateLoader()
示例8: __init__
def __init__(self, app, parsers={}, *args, **kwargs):
standalone.Reader.__init__(self, *args, **kwargs)
self.parser_map = {}
for suffix, parser_class in parsers.items():
if isinstance(parser_class, string_types):
parser_class = import_object(parser_class, 'source parser')
parser = parser_class()
if hasattr(parser, 'set_application'):
parser.set_application(app)
self.parser_map[suffix] = parser
示例9: deprecate_source_parsers
def deprecate_source_parsers(app, config):
# type: (Sphinx, Config) -> None
if config.source_parsers:
warnings.warn('The config variable "source_parsers" is deprecated. '
'Please use app.add_source_parser() API instead.',
RemovedInSphinx30Warning)
for suffix, parser in config.source_parsers.items():
if isinstance(parser, str):
parser = import_object(parser, 'source parser')
app.add_source_parser(suffix, parser)
示例10: __init__
def __init__(self, app, parsers={}, *args, **kwargs):
# type: (Sphinx, Dict[unicode, Parser], Any, Any) -> None
standalone.Reader.__init__(self, *args, **kwargs)
self.parser_map = {} # type: Dict[unicode, Parser]
for suffix, parser_class in parsers.items():
if isinstance(parser_class, string_types):
parser_class = import_object(parser_class, 'source parser') # type: ignore
parser = parser_class()
if hasattr(parser, 'set_application'):
parser.set_application(app)
self.parser_map[suffix] = parser
示例11: import_object
def import_object(self, objname, source=None):
# type: (str, str) -> Any
"""Import an object from a ``module.name`` string.
.. deprecated:: 1.8
Use ``sphinx.util.import_object()`` instead.
"""
warnings.warn('app.import_object() is deprecated. '
'Use sphinx.util.add_object_type() instead.',
RemovedInSphinx30Warning, stacklevel=2)
return import_object(objname, source=None)
示例12: init
def init(self, options):
type = options.get('type', 'default')
if type in self.splitters:
dotted_path = self.splitters[type]
else:
dotted_path = type
try:
self.splitter = import_object(dotted_path)(options)
except ExtensionError:
raise ExtensionError("Splitter module %r can't be imported" %
dotted_path)
示例13: init
def init(self, options):
# type: (Dict) -> None
type = options.get('type', 'sphinx.search.ja.DefaultSplitter')
if type in self.splitters:
dotted_path = self.splitters[type]
warnings.warn('html_search_options["type"]: %s is deprecated. '
'Please give "%s" instead.' % (type, dotted_path),
RemovedInSphinx30Warning)
else:
dotted_path = type
try:
self.splitter = import_object(dotted_path)(options)
except ExtensionError:
raise ExtensionError("Splitter module %r can't be imported" %
dotted_path)
示例14: import_object
def import_object(self, objname, source=None):
"""Import an object from a 'module.name' string."""
return import_object(objname, source=None)