本文整理汇总了Python中sphinx.ext.intersphinx.read_inventory_v2函数的典型用法代码示例。如果您正苦于以下问题:Python read_inventory_v2函数的具体用法?Python read_inventory_v2怎么用?Python read_inventory_v2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_inventory_v2函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_read_inventory_v2
def test_read_inventory_v2():
f = BytesIO(inventory_v2)
f.readline()
invdata1 = read_inventory_v2(f, "/util", posixpath.join)
# try again with a small buffer size to test the chunking algorithm
f = BytesIO(inventory_v2)
f.readline()
invdata2 = read_inventory_v2(f, "/util", posixpath.join, bufsize=5)
assert invdata1 == invdata2
assert len(invdata1["py:module"]) == 2
assert invdata1["py:module"]["module1"] == ("foo", "2.0", "/util/foo.html#module-module1", "Long Module desc")
assert invdata1["py:module"]["module2"] == ("foo", "2.0", "/util/foo.html#module-module2", "-")
assert invdata1["py:function"]["module1.func"][2] == "/util/sub/foo.html#module1.func"
assert invdata1["c:function"]["CFunc"][2] == "/util/cfunc.html#CFunc"
assert invdata1["std:term"]["a term"][2] == "/util/glossary.html#term-a-term"
开发者ID:QuLogic,项目名称:sphinx,代码行数:18,代码来源:test_ext_intersphinx.py
示例2: parse_sphinx_inventory
def parse_sphinx_inventory(self, version):
# Parsing objects.inv is strange.
urlpattern = 'http://docs.djangoproject.com/en/%s/%%s' % version
sphinx_index = urlpattern % '_objects/'
req = requests.get(sphinx_index)
if req.status_code in [200, 301]:
fp = urllib.urlopen(sphinx_index)
fp.readline()
return intersphinx.read_inventory_v2(fp, urlpattern, operator.mod)
return []
开发者ID:djangome,项目名称:djangome,代码行数:10,代码来源:refresh_objects.py
示例3: test_read_inventory_v2
def test_read_inventory_v2():
f = BytesIO(inventory_v2)
f.readline()
invdata1 = read_inventory_v2(f, '/util', posixpath.join)
# try again with a small buffer size to test the chunking algorithm
f = BytesIO(inventory_v2)
f.readline()
invdata2 = read_inventory_v2(f, '/util', posixpath.join, bufsize=5)
assert invdata1 == invdata2
assert len(invdata1['py:module']) == 2
assert invdata1['py:module']['module1'] == \
('foo', '2.0', '/util/foo.html#module-module1', 'Long Module desc')
assert invdata1['py:module']['module2'] == \
('foo', '2.0', '/util/foo.html#module-module2', '-')
assert invdata1['py:function']['module1.func'][2] == \
'/util/sub/foo.html#module1.func'
assert invdata1['c:function']['CFunc'][2] == '/util/cfunc.html#CFunc'
开发者ID:Spencerx,项目名称:sphinx,代码行数:20,代码来源:test_intersphinx.py
示例4: get_inventory
def get_inventory(url):
inv_url = urljoin(url, 'objects.inv')
f = urllib.urlopen(inv_url)
line = f.readline().rstrip().decode('utf-8')
if line == '# Sphinx inventory version 1':
invdata = read_inventory_v1(f, url, urljoin)
elif line == '# Sphinx inventory version 2':
invdata = read_inventory_v2(f, url, urljoin)
else:
raise ValueError(line)
return invdata
开发者ID:item4,项目名称:DogBot,代码行数:11,代码来源:flask.py
示例5: parse
def parse(self):
"""
Parse sphinx docs at self.doc_path.
yield `ParserEntry`s.
"""
with open(os.path.join(self.doc_path, "objects.inv"), "rb") as inv_f:
inv_f.readline() # skip version line that is verified in detection
for pe in _inv_to_entries(
read_inventory_v2(inv_f, "", os.path.join)
): # this is what Guido gave us `yield from` for :-|
yield pe
开发者ID:bossjones,项目名称:doc2dash,代码行数:12,代码来源:intersphinx.py
示例6: fetch_data
def fetch_data(url, inv):
f = open(inv, 'rb')
line = f.readline() # burn a line
invdata = read_inventory_v2(f, url or '', join)
if args.html:
print("<dl>")
for role in invdata:
start_role(role)
for item in invdata[role]:
(domain, version, url, title) = invdata[role][item]
start_item(role, item)
print_link(role, item, domain, title)
print_meta(role, item, domain, version, url, title)
end_item(role, item)
if args.html:
print("</dl>\n")
开发者ID:jantman,项目名称:misc-scripts,代码行数:16,代码来源:dump_sphinx_objects_inventory.py
示例7: fetch_data
def fetch_data(url,f):
line = f.readline() # burn a line
invdata = read_inventory_v2(f, url or '', join)
if (args.html):
print "<dl>"
for role in invdata:
start_role(role)
for item in invdata[role]:
(domain, version, url, title) = invdata[role][item]
print("{}:{} :: {}\n".format(role,item,invdata[role][item]))
start_item(role,item)
print_link(role,item,domain,title)
print_meta(role,item,domain,version,url,title)
end_item(role,item)
if (args.html):
print "</dl>\n"
开发者ID:DanLombardy,项目名称:python-dev-accelerator,代码行数:17,代码来源:inventory_reader.py
示例8: fetch_data
def fetch_data(url,inv):
f = open(inv, 'rb')
line = f.readline() # burn a line
invdata = read_inventory_v2(f, url or "", join)
if (args.html):
print("<dl>")
for role in invdata:
start_role(role)
for item in invdata[role]:
(domain, version, url, title) = invdata[role][item]
#sys.stderr.write("{}:{} :: {}\n".format(role,item,invdata[role][item]))
start_item(role,item)
print_link(role,item,domain,title)
print_meta(role,item,domain,version,url,title)
end_item(role,item)
if (args.html):
print("</dl>\n")
开发者ID:2-B,项目名称:pyproject,代码行数:18,代码来源:objinv.py
示例9: update_intersphinx
def update_intersphinx(version_pk, api=None):
if api is None:
api = tastyapi.api
version_data = api.version(version_pk).get()
version = make_api_version(version_data)
project = version.project
try:
object_file = version.project.find('objects.inv', version.slug)[0]
except IndexError:
print "Failed to find objects file"
return None
f = open(object_file)
f.readline()
urlpattern = "http://%s/en/%s/%%s" % (project.subdomain, version.slug)
data = intersphinx.read_inventory_v2(f, urlpattern, operator.mod)
for top_key in data.keys():
#print "KEY: %s" % top_key
inner_keys = data[top_key].keys()
for inner_key in inner_keys:
#print "INNER KEY: %s" % inner_key
_project, sphinx_version, url, title = data[top_key][inner_key]
try:
url_key = url.split('#')[1]
except IndexError:
# Invalid data
continue
if ":" in url_key:
#This dumps junk data into the url namespace we don't need
#print "INNER: %s->%s" % (inner_key, url)
save_term(version, inner_key, url)
else:
last_key = url_key.split('.')[-1]
if last_key != url_key:
#Only save last key if it differes
#print "LAST: %s->%s" % (last_key, url)
save_term(version, last_key, url)
#print "URL: %s->%s" % (url_key, url)
save_term(version, url_key, url)
开发者ID:awesome,项目名称:readthedocs.org,代码行数:41,代码来源:tasks.py
示例10: read_intersphinx
def read_intersphinx(project, file, urlpattern):
"""
Reads file as intersphinx format. Prepends the url pattern on the front of
URLs. URL Pattern should have a %s in it for string formatting.
Only supports intersphinx v2. It parses down into an effective set of data
that is:
{'<id>': [
"<project>", # From conf.py
"<version>", # From conf.py
"<url>", # With anchor
<title>" # Usually blank
]
}
We then smartly parse the anchor tag and add it into Redis.
"""
f = open(file)
f.readline()
data = intersphinx.read_inventory_v2(f, urlpattern, operator.mod)
for top_key in data.keys():
print "KEY: %s" % top_key
inner_keys = data[top_key].keys()
for inner_key in inner_keys:
print "INNER KEY: %s" % inner_key
_project, version, url, title = data[top_key][inner_key]
url_key = url.split('#')[1]
if ":" in url_key:
#This dumps junk data into the url namespace we don't need
print "INNER: %s->%s" % (inner_key, url)
safe_save(project, inner_key, url)
else:
last_key = url_key.split('.')[-1]
if last_key != url_key:
#Only save last key if it differes
print "LAST: %s->%s" % (last_key, url)
safe_save(project, last_key, url)
print "URL: %s->%s" % (url_key, url)
safe_save(project, url_key, url)
开发者ID:dirn,项目名称:slug.in,代码行数:40,代码来源:utils.py
示例11: update_intersphinx
@task
def update_intersphinx(version_pk):
version_data = api.version(version_pk).get()
version = make_api_version(version_data)
project = version.project
try:
object_file = version.project.find("objects.inv", version.slug)[0]
except IndexError, e:
print "Failed to find objects file"
return None
f = open(object_file)
f.readline()
urlpattern = "http://%s/en/%s/%%s" % (project.subdomain, version.slug)
data = intersphinx.read_inventory_v2(f, urlpattern, operator.mod)
for top_key in data.keys():
# print "KEY: %s" % top_key
inner_keys = data[top_key].keys()
for inner_key in inner_keys:
# print "INNER KEY: %s" % inner_key
_project, sphinx_version, url, title = data[top_key][inner_key]
try:
url_key = url.split("#")[1]
except IndexError:
# Invalid data
continue
if ":" in url_key:
# This dumps junk data into the url namespace we don't need
# print "INNER: %s->%s" % (inner_key, url)
save_term(version, inner_key, url)
开发者ID:billthornton,项目名称:readthedocs.org,代码行数:31,代码来源:tasks.py
示例12: open
from sphinx.ext.intersphinx import read_inventory_v2
from posixpath import join
url = "https://raw.github.com/xuru/vixDiskLib/gh-pages/"
inv = "objects.inv"
f = open(inv, 'rb')
line = f.readline()
invdata = read_inventory_v2(f, url, join)
print invdata.keys()
开发者ID:xuru,项目名称:xuru.github.com,代码行数:8,代码来源:test.py
示例13: getInventory
def getInventory(self):
f = urllib.urlopen(self.inventory_uri)
f.readline() # burn a line
self.inventory = read_inventory_v2(f, self.uri, join)
f.close()
self.inventory_items = self.inventory.get('std:label', {})
开发者ID:fsuter,项目名称:typo3-docs-typo3-org-resources,代码行数:6,代码来源:decode_sphinx_inventory.py
示例14: parse_sphinx_inventory
def parse_sphinx_inventory(self, version):
# Parsing objects.inv is strange.
urlpattern = 'http://docs.djangoproject.com/en/%s/%%s' % version
fp = urllib.urlopen(urlpattern % '_objects/')
fp.readline()
return intersphinx.read_inventory_v2(fp, urlpattern, operator.mod)
开发者ID:dadoeyad,项目名称:djangome,代码行数:6,代码来源:refresh_objects.py
注:本文中的sphinx.ext.intersphinx.read_inventory_v2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论