本文整理汇总了Python中unipath.Path.startswith方法的典型用法代码示例。如果您正苦于以下问题:Python Path.startswith方法的具体用法?Python Path.startswith怎么用?Python Path.startswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unipath.Path
的用法示例。
在下文中一共展示了Path.startswith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import startswith [as 别名]
def configure(globals_dict, prjspec=None):
intersphinx_mapping = dict()
# extlinks = dict()
# this = atelier.current_project
# if this is None:
# raise Exception("current_project in {} is None!".format(globals_dict['__file__']))
this_conf_file = Path(globals_dict['__file__']).resolve()
if prjspec:
if isinstance(prjspec, six.string_types):
prjspec = prjspec.split()
prjlist = [get_project_info_from_mod(n) for n in prjspec]
else:
prjlist = []
# for p in load_projects():
for p in reversed(list(load_projects())):
if this_conf_file.startswith(p.root_dir):
# print("20190122 {} startswith {}".format(this_conf_file, p.root_dir))
continue
prjlist.append(p)
# logger.info("20180907 prjlist {}".format(prjlist))
for prj in prjlist:
# This will load the `tasks.py` of other
# projects. Possible side effects.
# print("20180428 {} {}".format(prj.name, prj.config['doc_trees']))
# config = prj.inv_namespace.configuration()
# print("20180428 {} {}".format(prj.name, config['doc_trees']))
# ctx = Context(config)
# for doc_tree in prj.config['doc_trees']:
count = 0
for doc_tree in prj.get_doc_trees():
if not doc_tree.has_intersphinx:
logger.info("%s has no intersphinx", p)
continue
count += 1
urls = prj.get_xconfig('intersphinx_urls') or {}
url = urls.get(doc_tree.rel_path)
if not url:
if prjspec:
logger.warning(
"No intersphinx mapping for {} of {} ({})".format(
doc_tree.rel_path, prj.nickname, urls))
continue
p = None
if USE_LOCAL_BUILDS:
src_path = doc_tree.src_path
# print("20190306a", doc_tree, src_path)
if src_path is None or this_conf_file == src_path.child('conf.py'):
continue
# p = prj.root_dir.child(doc_tree, '.build', 'objects.inv')
p = src_path.child('.build', 'objects.inv')
if p.exists():
logger.info("Found local {}".format(p))
else:
logger.info("File %s does not exist", p)
p = None
# The unique identifier can be used to prefix cross-reference targets
# http://www.sphinx-doc.org/en/master/ext/intersphinx.html#confval-intersphinx_mapping
k = prj.nickname + doc_tree.rel_path
k = k.replace('_', '')
k = six.text_type(k) # make sure it's not newstr from
# future because that can cause
# problems when intersphinx tries to
# sort them
if k in intersphinx_mapping:
raise Exception("Duplicate intersphinx key {} used for {} "
"(you ask to redefine it to {})".format(
k, intersphinx_mapping[k], p))
intersphinx_mapping[k] = (url, p)
if count == 0 and prjspec:
logger.warning("No doctree for {}".format(prj))
# if prj.srcref_url:
# k = '%s_srcref' % prj.nickname
# extlinks[str(k)] = (prj.srcref_url, '')
# atelier.current_project = this
globals_dict.update(intersphinx_mapping=intersphinx_mapping)