本文整理汇总了Python中sphinx.environment.BuildEnvironment.frompickle方法的典型用法代码示例。如果您正苦于以下问题:Python BuildEnvironment.frompickle方法的具体用法?Python BuildEnvironment.frompickle怎么用?Python BuildEnvironment.frompickle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.environment.BuildEnvironment
的用法示例。
在下文中一共展示了BuildEnvironment.frompickle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_env
# 需要导入模块: from sphinx.environment import BuildEnvironment [as 别名]
# 或者: from sphinx.environment.BuildEnvironment import frompickle [as 别名]
def _init_env(self, freshenv):
if freshenv:
self.env = BuildEnvironment(self.srcdir, self.doctreedir,
self.config)
self.env.find_files(self.config)
for domain in self.domains.keys():
self.env.domains[domain] = self.domains[domain](self.env)
else:
try:
self.info(bold('loading pickled environment... '), nonl=True)
self.env = BuildEnvironment.frompickle(self.config,
path.join(self.doctreedir, ENV_PICKLE_FILENAME))
self.env.domains = {}
for domain in self.domains.keys():
# this can raise if the data version doesn't fit
self.env.domains[domain] = self.domains[domain](self.env)
self.info('done')
except Exception as err:
if type(err) is IOError and err.errno == ENOENT:
self.info('not yet created')
else:
self.info('failed: %s' % err)
return self._init_env(freshenv=True)
self.env.set_warnfunc(self.warn)
示例2: get_sphinx_environment
# 需要导入模块: from sphinx.environment import BuildEnvironment [as 别名]
# 或者: from sphinx.environment.BuildEnvironment import frompickle [as 别名]
def get_sphinx_environment(self):
"""
Returns the Sphinx environment for this project.
"""
from sphinx.environment import BuildEnvironment
class Foo(object):
pass
config = Foo()
config.values = []
env_pickle = os.path.join(self._doctrees_dir(), 'environment.pickle')
try:
env = BuildEnvironment.frompickle(config, env_pickle)
logger.debug("Opened Sphinx environment: %s", env_pickle)
return env
except IOError as err:
logger.debug("Failed to open Sphinx environment: %s", err)
pass
示例3: _init_env
# 需要导入模块: from sphinx.environment import BuildEnvironment [as 别名]
# 或者: from sphinx.environment.BuildEnvironment import frompickle [as 别名]
def _init_env(self, freshenv):
# type: (bool) -> None
if freshenv:
self.env = BuildEnvironment(self)
self.env.find_files(self.config, self.builder)
for domain in self.registry.create_domains(self.env):
self.env.domains[domain.name] = domain
else:
try:
logger.info(bold(__('loading pickled environment... ')), nonl=True)
filename = path.join(self.doctreedir, ENV_PICKLE_FILENAME)
self.env = BuildEnvironment.frompickle(filename, self)
self.env.domains = {}
for domain in self.registry.create_domains(self.env):
# this can raise if the data version doesn't fit
self.env.domains[domain.name] = domain
logger.info(__('done'))
except Exception as err:
if isinstance(err, IOError) and err.errno == ENOENT:
logger.info(__('not yet created'))
else:
logger.info(__('failed: %s'), err)
self._init_env(freshenv=True)
示例4: _init_env
# 需要导入模块: from sphinx.environment import BuildEnvironment [as 别名]
# 或者: from sphinx.environment.BuildEnvironment import frompickle [as 别名]
def _init_env(self, freshenv):
# type: (bool) -> None
filename = path.join(self.doctreedir, ENV_PICKLE_FILENAME)
if freshenv or not os.path.exists(filename):
self.env = BuildEnvironment(self)
self.env.find_files(self.config, self.builder)
for domain in self.registry.create_domains(self.env):
self.env.domains[domain.name] = domain
else:
try:
logger.info(bold(__('loading pickled environment... ')), nonl=True)
self.env = BuildEnvironment.frompickle(filename, self)
needed, reason = self.env.need_refresh(self)
if needed:
raise IOError(reason)
self.env.domains = {}
for domain in self.registry.create_domains(self.env):
# this can raise if the data version doesn't fit
self.env.domains[domain.name] = domain
logger.info(__('done'))
except Exception as err:
logger.info(__('failed: %s'), err)
self._init_env(freshenv=True)