本文整理汇总了Python中utils.extract_nodes函数的典型用法代码示例。如果您正苦于以下问题:Python extract_nodes函数的具体用法?Python extract_nodes怎么用?Python extract_nodes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extract_nodes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: author_keywords
def author_keywords(soup):
# A few articles have kwd-group with no kwd-group-type, so account for those
tags = extract_nodes(soup, "kwd-group")
keyword_tags = []
for tag in tags:
if (tag.get("kwd-group-type") == "author-keywords"
or tag.get("kwd-group-type") is None):
keyword_tags += filter(lambda tag: tag.name == "kwd", tag)
return keyword_tags
示例2: full_subject_area
def full_subject_area(soup, subject_group_type=None):
subject_group_tags = extract_nodes(soup, "subj-group")
subject_group_tags = filter(lambda tag: tag.parent.name == "article-categories"
and tag.parent.parent.name == "article-meta", subject_group_tags)
if subject_group_type:
subject_group_tags = filter(lambda tag:
tag.get("subj-group-type" == subject_group_type))
return subject_group_tags
示例3: subject_area
def subject_area(soup, subject_group_type = None):
# Supports all subject areas or just particular ones filtered by
subject_area_tags = []
tags = extract_nodes(soup, "subject")
subject_area_tags = filter(lambda tag: tag.parent.name == "subj-group" \
and tag.parent.parent.name == "article-categories" \
and tag.parent.parent.parent.name == "article-meta", tags)
if subject_group_type:
subject_area_tags = filter(lambda tag:
tag.parent.get("subj-group-type") == subject_group_type, tags)
return subject_area_tags
示例4: simulate
def simulate(vbmap):
pylab.figure()
nodes = extract_nodes(vbmap['map'])
nodes_count = len(nodes)
vbmaps = simulate_failovers(vbmap)
charts_count = len(vbmaps)
rows = cols = int(math.ceil(math.sqrt(charts_count)))
def plot(vbmap, chart):
pylab.subplot(rows, cols, chart)
masters = [n for n in extract_masters(vbmap) if n is not None]
pylab.xticks([i + 0.5 for i in xrange(nodes_count)], nodes)
pylab.hist(masters, bins=xrange(nodes_count + 1))
pylab.xlabel("Nodes")
pylab.ylabel("Number of vbuckets")
pylab.legend()
for chart, vbmap in enumerate(vbmaps, 1):
plot(vbmap, chart)
示例5: funding_statement
def funding_statement(soup):
return first(extract_nodes(soup, "funding-statement"))
示例6: copyright_year
def copyright_year(soup):
return first(extract_nodes(permissions(soup), "copyright-year"))
示例7: article_title
def article_title(soup):
return first(extract_nodes(soup, "article-title"))
示例8: licence
def licence(soup):
return first(extract_nodes(permissions(soup), "license"))
示例9: conflict
def conflict(soup):
return extract_nodes(soup, "fn", attr = "fn-type", value = "conflict")
示例10: publisher
def publisher(soup):
return first(extract_nodes(soup, "publisher-name"))
示例11: journal_issn
def journal_issn(soup, pub_format):
return first(extract_nodes(soup, "issn", attr = "publication-format", value = pub_format))
示例12: journal_title
def journal_title(soup):
return first(extract_nodes(soup, "journal-title"))
示例13: journal_id
def journal_id(soup):
# the first non-nil tag
return firstnn(extract_nodes(soup, "journal-id", attr = "journal-id-type", value = "hwp"))
示例14: publisher_id
def publisher_id(soup):
article_id_tags = extract_nodes(soup, "article-id", attr = "pub-id-type", value = "publisher-id")
# the first article-id tag whose parent is article-meta
return first(filter(lambda tag: tag.parent.name == "article-meta", article_id_tags))
示例15: doi
def doi(soup):
doi_tags = extract_nodes(soup, "article-id", attr = "pub-id-type", value = "doi")
# the first article-id tag whose parent is article-meta
return first(filter(lambda tag: tag.parent.name == "article-meta", doi_tags))