repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
elifesciences/elife-tools | elifetools/parseJATS.py | graphics | def graphics(soup):
"""
All graphic tags and some associated data about the related component doi
and the parent of that doi (not always present), and whether it is
part of a figure supplement
"""
graphics = []
graphic_tags = raw_parser.graphic(soup)
position = 1
for tag in graphi... | python | def graphics(soup):
"""
All graphic tags and some associated data about the related component doi
and the parent of that doi (not always present), and whether it is
part of a figure supplement
"""
graphics = []
graphic_tags = raw_parser.graphic(soup)
position = 1
for tag in graphi... | [
"def",
"graphics",
"(",
"soup",
")",
":",
"graphics",
"=",
"[",
"]",
"graphic_tags",
"=",
"raw_parser",
".",
"graphic",
"(",
"soup",
")",
"position",
"=",
"1",
"for",
"tag",
"in",
"graphic_tags",
":",
"graphic_item",
"=",
"{",
"}",
"copy_attribute",
"(",... | All graphic tags and some associated data about the related component doi
and the parent of that doi (not always present), and whether it is
part of a figure supplement | [
"All",
"graphic",
"tags",
"and",
"some",
"associated",
"data",
"about",
"the",
"related",
"component",
"doi",
"and",
"the",
"parent",
"of",
"that",
"doi",
"(",
"not",
"always",
"present",
")",
"and",
"whether",
"it",
"is",
"part",
"of",
"a",
"figure",
"s... | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L824-L877 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | inline_graphics | def inline_graphics(soup):
"""
inline-graphic tags
"""
inline_graphics = []
inline_graphic_tags = raw_parser.inline_graphic(soup)
position = 1
for tag in inline_graphic_tags:
item = {}
copy_attribute(tag.attrs, 'xlink:href', item, 'xlink_href')
# Get the tag type... | python | def inline_graphics(soup):
"""
inline-graphic tags
"""
inline_graphics = []
inline_graphic_tags = raw_parser.inline_graphic(soup)
position = 1
for tag in inline_graphic_tags:
item = {}
copy_attribute(tag.attrs, 'xlink:href', item, 'xlink_href')
# Get the tag type... | [
"def",
"inline_graphics",
"(",
"soup",
")",
":",
"inline_graphics",
"=",
"[",
"]",
"inline_graphic_tags",
"=",
"raw_parser",
".",
"inline_graphic",
"(",
"soup",
")",
"position",
"=",
"1",
"for",
"tag",
"in",
"inline_graphic_tags",
":",
"item",
"=",
"{",
"}",... | inline-graphic tags | [
"inline",
"-",
"graphic",
"tags"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L879-L906 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | self_uri | def self_uri(soup):
"""
self-uri tags
"""
self_uri = []
self_uri_tags = raw_parser.self_uri(soup)
position = 1
for tag in self_uri_tags:
item = {}
copy_attribute(tag.attrs, 'xlink:href', item, 'xlink_href')
copy_attribute(tag.attrs, 'content-type', item)
# ... | python | def self_uri(soup):
"""
self-uri tags
"""
self_uri = []
self_uri_tags = raw_parser.self_uri(soup)
position = 1
for tag in self_uri_tags:
item = {}
copy_attribute(tag.attrs, 'xlink:href', item, 'xlink_href')
copy_attribute(tag.attrs, 'content-type', item)
# ... | [
"def",
"self_uri",
"(",
"soup",
")",
":",
"self_uri",
"=",
"[",
"]",
"self_uri_tags",
"=",
"raw_parser",
".",
"self_uri",
"(",
"soup",
")",
"position",
"=",
"1",
"for",
"tag",
"in",
"self_uri_tags",
":",
"item",
"=",
"{",
"}",
"copy_attribute",
"(",
"t... | self-uri tags | [
"self",
"-",
"uri",
"tags"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L908-L934 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | supplementary_material | def supplementary_material(soup):
"""
supplementary-material tags
"""
supplementary_material = []
supplementary_material_tags = raw_parser.supplementary_material(soup)
position = 1
for tag in supplementary_material_tags:
item = {}
copy_attribute(tag.attrs, 'id', item)
... | python | def supplementary_material(soup):
"""
supplementary-material tags
"""
supplementary_material = []
supplementary_material_tags = raw_parser.supplementary_material(soup)
position = 1
for tag in supplementary_material_tags:
item = {}
copy_attribute(tag.attrs, 'id', item)
... | [
"def",
"supplementary_material",
"(",
"soup",
")",
":",
"supplementary_material",
"=",
"[",
"]",
"supplementary_material_tags",
"=",
"raw_parser",
".",
"supplementary_material",
"(",
"soup",
")",
"position",
"=",
"1",
"for",
"tag",
"in",
"supplementary_material_tags",... | supplementary-material tags | [
"supplementary",
"-",
"material",
"tags"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L936-L970 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | contrib_email | def contrib_email(contrib_tag):
"""
Given a contrib tag, look for an email tag, and
only return the value if it is not inside an aff tag
"""
email = []
for email_tag in extract_nodes(contrib_tag, "email"):
if email_tag.parent.name != "aff":
email.append(email_tag.text)
re... | python | def contrib_email(contrib_tag):
"""
Given a contrib tag, look for an email tag, and
only return the value if it is not inside an aff tag
"""
email = []
for email_tag in extract_nodes(contrib_tag, "email"):
if email_tag.parent.name != "aff":
email.append(email_tag.text)
re... | [
"def",
"contrib_email",
"(",
"contrib_tag",
")",
":",
"email",
"=",
"[",
"]",
"for",
"email_tag",
"in",
"extract_nodes",
"(",
"contrib_tag",
",",
"\"email\"",
")",
":",
"if",
"email_tag",
".",
"parent",
".",
"name",
"!=",
"\"aff\"",
":",
"email",
".",
"a... | Given a contrib tag, look for an email tag, and
only return the value if it is not inside an aff tag | [
"Given",
"a",
"contrib",
"tag",
"look",
"for",
"an",
"email",
"tag",
"and",
"only",
"return",
"the",
"value",
"if",
"it",
"is",
"not",
"inside",
"an",
"aff",
"tag"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L979-L988 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | contrib_phone | def contrib_phone(contrib_tag):
"""
Given a contrib tag, look for an phone tag
"""
phone = None
if raw_parser.phone(contrib_tag):
phone = first(raw_parser.phone(contrib_tag)).text
return phone | python | def contrib_phone(contrib_tag):
"""
Given a contrib tag, look for an phone tag
"""
phone = None
if raw_parser.phone(contrib_tag):
phone = first(raw_parser.phone(contrib_tag)).text
return phone | [
"def",
"contrib_phone",
"(",
"contrib_tag",
")",
":",
"phone",
"=",
"None",
"if",
"raw_parser",
".",
"phone",
"(",
"contrib_tag",
")",
":",
"phone",
"=",
"first",
"(",
"raw_parser",
".",
"phone",
"(",
"contrib_tag",
")",
")",
".",
"text",
"return",
"phon... | Given a contrib tag, look for an phone tag | [
"Given",
"a",
"contrib",
"tag",
"look",
"for",
"an",
"phone",
"tag"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L990-L997 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | contrib_inline_aff | def contrib_inline_aff(contrib_tag):
"""
Given a contrib tag, look for an aff tag directly inside it
"""
aff_tags = []
for child_tag in contrib_tag:
if child_tag and child_tag.name and child_tag.name == "aff":
aff_tags.append(child_tag)
return aff_tags | python | def contrib_inline_aff(contrib_tag):
"""
Given a contrib tag, look for an aff tag directly inside it
"""
aff_tags = []
for child_tag in contrib_tag:
if child_tag and child_tag.name and child_tag.name == "aff":
aff_tags.append(child_tag)
return aff_tags | [
"def",
"contrib_inline_aff",
"(",
"contrib_tag",
")",
":",
"aff_tags",
"=",
"[",
"]",
"for",
"child_tag",
"in",
"contrib_tag",
":",
"if",
"child_tag",
"and",
"child_tag",
".",
"name",
"and",
"child_tag",
".",
"name",
"==",
"\"aff\"",
":",
"aff_tags",
".",
... | Given a contrib tag, look for an aff tag directly inside it | [
"Given",
"a",
"contrib",
"tag",
"look",
"for",
"an",
"aff",
"tag",
"directly",
"inside",
"it"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L999-L1007 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | contrib_xref | def contrib_xref(contrib_tag, ref_type):
"""
Given a contrib tag, look for an xref tag of type ref_type directly inside the contrib tag
"""
aff_tags = []
for child_tag in contrib_tag:
if (child_tag and child_tag.name and child_tag.name == "xref"
and child_tag.get('ref-type') and ... | python | def contrib_xref(contrib_tag, ref_type):
"""
Given a contrib tag, look for an xref tag of type ref_type directly inside the contrib tag
"""
aff_tags = []
for child_tag in contrib_tag:
if (child_tag and child_tag.name and child_tag.name == "xref"
and child_tag.get('ref-type') and ... | [
"def",
"contrib_xref",
"(",
"contrib_tag",
",",
"ref_type",
")",
":",
"aff_tags",
"=",
"[",
"]",
"for",
"child_tag",
"in",
"contrib_tag",
":",
"if",
"(",
"child_tag",
"and",
"child_tag",
".",
"name",
"and",
"child_tag",
".",
"name",
"==",
"\"xref\"",
"and"... | Given a contrib tag, look for an xref tag of type ref_type directly inside the contrib tag | [
"Given",
"a",
"contrib",
"tag",
"look",
"for",
"an",
"xref",
"tag",
"of",
"type",
"ref_type",
"directly",
"inside",
"the",
"contrib",
"tag"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1009-L1018 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | all_contributors | def all_contributors(soup, detail="brief"):
"find all contributors not contrained to only the ones in article meta"
contrib_tags = raw_parser.contributors(soup)
contributors = format_authors(soup, contrib_tags, detail)
return contributors | python | def all_contributors(soup, detail="brief"):
"find all contributors not contrained to only the ones in article meta"
contrib_tags = raw_parser.contributors(soup)
contributors = format_authors(soup, contrib_tags, detail)
return contributors | [
"def",
"all_contributors",
"(",
"soup",
",",
"detail",
"=",
"\"brief\"",
")",
":",
"contrib_tags",
"=",
"raw_parser",
".",
"contributors",
"(",
"soup",
")",
"contributors",
"=",
"format_authors",
"(",
"soup",
",",
"contrib_tags",
",",
"detail",
")",
"return",
... | find all contributors not contrained to only the ones in article meta | [
"find",
"all",
"contributors",
"not",
"contrained",
"to",
"only",
"the",
"ones",
"in",
"article",
"meta"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1205-L1209 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | authors_non_byline | def authors_non_byline(soup, detail="full"):
"""Non-byline authors for group author members"""
# Get a filtered list of contributors, in order to get their group-author-id
contrib_type = "author non-byline"
contributors_ = contributors(soup, detail)
non_byline_authors = [author for author in contrib... | python | def authors_non_byline(soup, detail="full"):
"""Non-byline authors for group author members"""
# Get a filtered list of contributors, in order to get their group-author-id
contrib_type = "author non-byline"
contributors_ = contributors(soup, detail)
non_byline_authors = [author for author in contrib... | [
"def",
"authors_non_byline",
"(",
"soup",
",",
"detail",
"=",
"\"full\"",
")",
":",
"# Get a filtered list of contributors, in order to get their group-author-id",
"contrib_type",
"=",
"\"author non-byline\"",
"contributors_",
"=",
"contributors",
"(",
"soup",
",",
"detail",
... | Non-byline authors for group author members | [
"Non",
"-",
"byline",
"authors",
"for",
"group",
"author",
"members"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1222-L1234 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | refs | def refs(soup):
"""Find and return all the references"""
tags = raw_parser.ref_list(soup)
refs = []
position = 1
article_doi = doi(soup)
for tag in tags:
ref = {}
ref['ref'] = ref_text(tag)
# ref_id
copy_attribute(tag.attrs, "id", ref)
# article_title... | python | def refs(soup):
"""Find and return all the references"""
tags = raw_parser.ref_list(soup)
refs = []
position = 1
article_doi = doi(soup)
for tag in tags:
ref = {}
ref['ref'] = ref_text(tag)
# ref_id
copy_attribute(tag.attrs, "id", ref)
# article_title... | [
"def",
"refs",
"(",
"soup",
")",
":",
"tags",
"=",
"raw_parser",
".",
"ref_list",
"(",
"soup",
")",
"refs",
"=",
"[",
"]",
"position",
"=",
"1",
"article_doi",
"=",
"doi",
"(",
"soup",
")",
"for",
"tag",
"in",
"tags",
":",
"ref",
"=",
"{",
"}",
... | Find and return all the references | [
"Find",
"and",
"return",
"all",
"the",
"references"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1340-L1484 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | extract_component_doi | def extract_component_doi(tag, nodenames):
"""
Used to get component DOI from a tag and confirm it is actually for that tag
and it is not for one of its children in the list of nodenames
"""
component_doi = None
if(tag.name == "sub-article"):
component_doi = doi_uri_to_doi(node_text(fir... | python | def extract_component_doi(tag, nodenames):
"""
Used to get component DOI from a tag and confirm it is actually for that tag
and it is not for one of its children in the list of nodenames
"""
component_doi = None
if(tag.name == "sub-article"):
component_doi = doi_uri_to_doi(node_text(fir... | [
"def",
"extract_component_doi",
"(",
"tag",
",",
"nodenames",
")",
":",
"component_doi",
"=",
"None",
"if",
"(",
"tag",
".",
"name",
"==",
"\"sub-article\"",
")",
":",
"component_doi",
"=",
"doi_uri_to_doi",
"(",
"node_text",
"(",
"first",
"(",
"raw_parser",
... | Used to get component DOI from a tag and confirm it is actually for that tag
and it is not for one of its children in the list of nodenames | [
"Used",
"to",
"get",
"component",
"DOI",
"from",
"a",
"tag",
"and",
"confirm",
"it",
"is",
"actually",
"for",
"that",
"tag",
"and",
"it",
"is",
"not",
"for",
"one",
"of",
"its",
"children",
"in",
"the",
"list",
"of",
"nodenames"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1486-L1507 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | components | def components(soup):
"""
Find the components, i.e. those parts that would be assigned
a unique component DOI, such as figures, tables, etc.
- position is in what order the tag appears in the entire set of nodes
- ordinal is in what order it is for all the tags of its own type
"""
components... | python | def components(soup):
"""
Find the components, i.e. those parts that would be assigned
a unique component DOI, such as figures, tables, etc.
- position is in what order the tag appears in the entire set of nodes
- ordinal is in what order it is for all the tags of its own type
"""
components... | [
"def",
"components",
"(",
"soup",
")",
":",
"components",
"=",
"[",
"]",
"nodenames",
"=",
"[",
"\"abstract\"",
",",
"\"fig\"",
",",
"\"table-wrap\"",
",",
"\"media\"",
",",
"\"chem-struct-wrap\"",
",",
"\"sub-article\"",
",",
"\"supplementary-material\"",
",",
... | Find the components, i.e. those parts that would be assigned
a unique component DOI, such as figures, tables, etc.
- position is in what order the tag appears in the entire set of nodes
- ordinal is in what order it is for all the tags of its own type | [
"Find",
"the",
"components",
"i",
".",
"e",
".",
"those",
"parts",
"that",
"would",
"be",
"assigned",
"a",
"unique",
"component",
"DOI",
"such",
"as",
"figures",
"tables",
"etc",
".",
"-",
"position",
"is",
"in",
"what",
"order",
"the",
"tag",
"appears",... | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1509-L1695 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | correspondence | def correspondence(soup):
"""
Find the corresp tags included in author-notes
for primary correspondence
"""
correspondence = []
author_notes_nodes = raw_parser.author_notes(soup)
if author_notes_nodes:
corresp_nodes = raw_parser.corresp(author_notes_nodes)
for tag in corres... | python | def correspondence(soup):
"""
Find the corresp tags included in author-notes
for primary correspondence
"""
correspondence = []
author_notes_nodes = raw_parser.author_notes(soup)
if author_notes_nodes:
corresp_nodes = raw_parser.corresp(author_notes_nodes)
for tag in corres... | [
"def",
"correspondence",
"(",
"soup",
")",
":",
"correspondence",
"=",
"[",
"]",
"author_notes_nodes",
"=",
"raw_parser",
".",
"author_notes",
"(",
"soup",
")",
"if",
"author_notes_nodes",
":",
"corresp_nodes",
"=",
"raw_parser",
".",
"corresp",
"(",
"author_not... | Find the corresp tags included in author-notes
for primary correspondence | [
"Find",
"the",
"corresp",
"tags",
"included",
"in",
"author",
"-",
"notes",
"for",
"primary",
"correspondence"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1699-L1713 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | author_notes | def author_notes(soup):
"""
Find the fn tags included in author-notes
"""
author_notes = []
author_notes_section = raw_parser.author_notes(soup)
if author_notes_section:
fn_nodes = raw_parser.fn(author_notes_section)
for tag in fn_nodes:
if 'fn-type' in tag.attrs:
... | python | def author_notes(soup):
"""
Find the fn tags included in author-notes
"""
author_notes = []
author_notes_section = raw_parser.author_notes(soup)
if author_notes_section:
fn_nodes = raw_parser.fn(author_notes_section)
for tag in fn_nodes:
if 'fn-type' in tag.attrs:
... | [
"def",
"author_notes",
"(",
"soup",
")",
":",
"author_notes",
"=",
"[",
"]",
"author_notes_section",
"=",
"raw_parser",
".",
"author_notes",
"(",
"soup",
")",
"if",
"author_notes_section",
":",
"fn_nodes",
"=",
"raw_parser",
".",
"fn",
"(",
"author_notes_section... | Find the fn tags included in author-notes | [
"Find",
"the",
"fn",
"tags",
"included",
"in",
"author",
"-",
"notes"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1740-L1754 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | full_author_notes | def full_author_notes(soup, fntype_filter=None):
"""
Find the fn tags included in author-notes
"""
notes = []
author_notes_section = raw_parser.author_notes(soup)
if author_notes_section:
fn_nodes = raw_parser.fn(author_notes_section)
notes = footnotes(fn_nodes, fntype_filter)
... | python | def full_author_notes(soup, fntype_filter=None):
"""
Find the fn tags included in author-notes
"""
notes = []
author_notes_section = raw_parser.author_notes(soup)
if author_notes_section:
fn_nodes = raw_parser.fn(author_notes_section)
notes = footnotes(fn_nodes, fntype_filter)
... | [
"def",
"full_author_notes",
"(",
"soup",
",",
"fntype_filter",
"=",
"None",
")",
":",
"notes",
"=",
"[",
"]",
"author_notes_section",
"=",
"raw_parser",
".",
"author_notes",
"(",
"soup",
")",
"if",
"author_notes_section",
":",
"fn_nodes",
"=",
"raw_parser",
".... | Find the fn tags included in author-notes | [
"Find",
"the",
"fn",
"tags",
"included",
"in",
"author",
"-",
"notes"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1757-L1768 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | competing_interests | def competing_interests(soup, fntype_filter):
"""
Find the fn tags included in the competing interest
"""
competing_interests_section = extract_nodes(soup, "fn-group", attr="content-type", value="competing-interest")
if not competing_interests_section:
return None
fn = extract_nodes(fir... | python | def competing_interests(soup, fntype_filter):
"""
Find the fn tags included in the competing interest
"""
competing_interests_section = extract_nodes(soup, "fn-group", attr="content-type", value="competing-interest")
if not competing_interests_section:
return None
fn = extract_nodes(fir... | [
"def",
"competing_interests",
"(",
"soup",
",",
"fntype_filter",
")",
":",
"competing_interests_section",
"=",
"extract_nodes",
"(",
"soup",
",",
"\"fn-group\"",
",",
"attr",
"=",
"\"content-type\"",
",",
"value",
"=",
"\"competing-interest\"",
")",
"if",
"not",
"... | Find the fn tags included in the competing interest | [
"Find",
"the",
"fn",
"tags",
"included",
"in",
"the",
"competing",
"interest"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1771-L1782 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | author_contributions | def author_contributions(soup, fntype_filter):
"""
Find the fn tags included in the competing interest
"""
author_contributions_section = extract_nodes(soup, "fn-group", attr="content-type", value="author-contribution")
if not author_contributions_section:
return None
fn = extract_nodes... | python | def author_contributions(soup, fntype_filter):
"""
Find the fn tags included in the competing interest
"""
author_contributions_section = extract_nodes(soup, "fn-group", attr="content-type", value="author-contribution")
if not author_contributions_section:
return None
fn = extract_nodes... | [
"def",
"author_contributions",
"(",
"soup",
",",
"fntype_filter",
")",
":",
"author_contributions_section",
"=",
"extract_nodes",
"(",
"soup",
",",
"\"fn-group\"",
",",
"attr",
"=",
"\"content-type\"",
",",
"value",
"=",
"\"author-contribution\"",
")",
"if",
"not",
... | Find the fn tags included in the competing interest | [
"Find",
"the",
"fn",
"tags",
"included",
"in",
"the",
"competing",
"interest"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1806-L1817 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | full_award_groups | def full_award_groups(soup):
"""
Find the award-group items and return a list of details
"""
award_groups = []
funding_group_section = extract_nodes(soup, "funding-group")
# counter for auto generated id values, if required
generated_id_counter = 1
for fg in funding_group_section:
... | python | def full_award_groups(soup):
"""
Find the award-group items and return a list of details
"""
award_groups = []
funding_group_section = extract_nodes(soup, "funding-group")
# counter for auto generated id values, if required
generated_id_counter = 1
for fg in funding_group_section:
... | [
"def",
"full_award_groups",
"(",
"soup",
")",
":",
"award_groups",
"=",
"[",
"]",
"funding_group_section",
"=",
"extract_nodes",
"(",
"soup",
",",
"\"funding-group\"",
")",
"# counter for auto generated id values, if required",
"generated_id_counter",
"=",
"1",
"for",
"... | Find the award-group items and return a list of details | [
"Find",
"the",
"award",
"-",
"group",
"items",
"and",
"return",
"a",
"list",
"of",
"details"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1836-L1871 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | award_groups | def award_groups(soup):
"""
Find the award-group items and return a list of details
"""
award_groups = []
funding_group_section = extract_nodes(soup, "funding-group")
for fg in funding_group_section:
award_group_tags = extract_nodes(fg, "award-group")
for ag in award_group_tag... | python | def award_groups(soup):
"""
Find the award-group items and return a list of details
"""
award_groups = []
funding_group_section = extract_nodes(soup, "funding-group")
for fg in funding_group_section:
award_group_tags = extract_nodes(fg, "award-group")
for ag in award_group_tag... | [
"def",
"award_groups",
"(",
"soup",
")",
":",
"award_groups",
"=",
"[",
"]",
"funding_group_section",
"=",
"extract_nodes",
"(",
"soup",
",",
"\"funding-group\"",
")",
"for",
"fg",
"in",
"funding_group_section",
":",
"award_group_tags",
"=",
"extract_nodes",
"(",
... | Find the award-group items and return a list of details | [
"Find",
"the",
"award",
"-",
"group",
"items",
"and",
"return",
"a",
"list",
"of",
"details"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1875-L1896 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | award_group_funding_source | def award_group_funding_source(tag):
"""
Given a funding group element
Find the award group funding sources, one for each
item found in the get_funding_group section
"""
award_group_funding_source = []
funding_source_tags = extract_nodes(tag, "funding-source")
for t in funding_source_tag... | python | def award_group_funding_source(tag):
"""
Given a funding group element
Find the award group funding sources, one for each
item found in the get_funding_group section
"""
award_group_funding_source = []
funding_source_tags = extract_nodes(tag, "funding-source")
for t in funding_source_tag... | [
"def",
"award_group_funding_source",
"(",
"tag",
")",
":",
"award_group_funding_source",
"=",
"[",
"]",
"funding_source_tags",
"=",
"extract_nodes",
"(",
"tag",
",",
"\"funding-source\"",
")",
"for",
"t",
"in",
"funding_source_tags",
":",
"award_group_funding_source",
... | Given a funding group element
Find the award group funding sources, one for each
item found in the get_funding_group section | [
"Given",
"a",
"funding",
"group",
"element",
"Find",
"the",
"award",
"group",
"funding",
"sources",
"one",
"for",
"each",
"item",
"found",
"in",
"the",
"get_funding_group",
"section"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1900-L1910 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | full_award_group_funding_source | def full_award_group_funding_source(tag):
"""
Given a funding group element
Find the award group funding sources, one for each
item found in the get_funding_group section
"""
award_group_funding_sources = []
funding_source_nodes = extract_nodes(tag, "funding-source")
for funding_source_n... | python | def full_award_group_funding_source(tag):
"""
Given a funding group element
Find the award group funding sources, one for each
item found in the get_funding_group section
"""
award_group_funding_sources = []
funding_source_nodes = extract_nodes(tag, "funding-source")
for funding_source_n... | [
"def",
"full_award_group_funding_source",
"(",
"tag",
")",
":",
"award_group_funding_sources",
"=",
"[",
"]",
"funding_source_nodes",
"=",
"extract_nodes",
"(",
"tag",
",",
"\"funding-source\"",
")",
"for",
"funding_source_node",
"in",
"funding_source_nodes",
":",
"awar... | Given a funding group element
Find the award group funding sources, one for each
item found in the get_funding_group section | [
"Given",
"a",
"funding",
"group",
"element",
"Find",
"the",
"award",
"group",
"funding",
"sources",
"one",
"for",
"each",
"item",
"found",
"in",
"the",
"get_funding_group",
"section"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1913-L1942 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | award_group_award_id | def award_group_award_id(tag):
"""
Find the award group award id, one for each
item found in the get_funding_group section
"""
award_group_award_id = []
award_id_tags = extract_nodes(tag, "award-id")
for t in award_id_tags:
award_group_award_id.append(t.text)
return award_group_a... | python | def award_group_award_id(tag):
"""
Find the award group award id, one for each
item found in the get_funding_group section
"""
award_group_award_id = []
award_id_tags = extract_nodes(tag, "award-id")
for t in award_id_tags:
award_group_award_id.append(t.text)
return award_group_a... | [
"def",
"award_group_award_id",
"(",
"tag",
")",
":",
"award_group_award_id",
"=",
"[",
"]",
"award_id_tags",
"=",
"extract_nodes",
"(",
"tag",
",",
"\"award-id\"",
")",
"for",
"t",
"in",
"award_id_tags",
":",
"award_group_award_id",
".",
"append",
"(",
"t",
".... | Find the award group award id, one for each
item found in the get_funding_group section | [
"Find",
"the",
"award",
"group",
"award",
"id",
"one",
"for",
"each",
"item",
"found",
"in",
"the",
"get_funding_group",
"section"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1946-L1955 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | award_group_principal_award_recipient | def award_group_principal_award_recipient(tag):
"""
Find the award group principal award recipient, one for each
item found in the get_funding_group section
"""
award_group_principal_award_recipient = []
principal_award_recipients = extract_nodes(tag, "principal-award-recipient")
for t in p... | python | def award_group_principal_award_recipient(tag):
"""
Find the award group principal award recipient, one for each
item found in the get_funding_group section
"""
award_group_principal_award_recipient = []
principal_award_recipients = extract_nodes(tag, "principal-award-recipient")
for t in p... | [
"def",
"award_group_principal_award_recipient",
"(",
"tag",
")",
":",
"award_group_principal_award_recipient",
"=",
"[",
"]",
"principal_award_recipients",
"=",
"extract_nodes",
"(",
"tag",
",",
"\"principal-award-recipient\"",
")",
"for",
"t",
"in",
"principal_award_recipi... | Find the award group principal award recipient, one for each
item found in the get_funding_group section | [
"Find",
"the",
"award",
"group",
"principal",
"award",
"recipient",
"one",
"for",
"each",
"item",
"found",
"in",
"the",
"get_funding_group",
"section"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1958-L1987 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | object_id_doi | def object_id_doi(tag, parent_tag_name=None):
"""DOI in an object-id tag found inside the tag"""
doi = None
object_id = None
object_ids = raw_parser.object_id(tag, "doi")
if object_ids:
object_id = first([id_ for id_ in object_ids])
if parent_tag_name and object_id and object_id.parent.n... | python | def object_id_doi(tag, parent_tag_name=None):
"""DOI in an object-id tag found inside the tag"""
doi = None
object_id = None
object_ids = raw_parser.object_id(tag, "doi")
if object_ids:
object_id = first([id_ for id_ in object_ids])
if parent_tag_name and object_id and object_id.parent.n... | [
"def",
"object_id_doi",
"(",
"tag",
",",
"parent_tag_name",
"=",
"None",
")",
":",
"doi",
"=",
"None",
"object_id",
"=",
"None",
"object_ids",
"=",
"raw_parser",
".",
"object_id",
"(",
"tag",
",",
"\"doi\"",
")",
"if",
"object_ids",
":",
"object_id",
"=",
... | DOI in an object-id tag found inside the tag | [
"DOI",
"in",
"an",
"object",
"-",
"id",
"tag",
"found",
"inside",
"the",
"tag"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L1989-L2000 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | title_tag_inspected | def title_tag_inspected(tag, parent_tag_name=None, p_parent_tag_name=None, direct_sibling_only=False):
"""Extract the title tag and sometimes inspect its parents"""
title_tag = None
if direct_sibling_only is True:
for sibling_tag in tag:
if sibling_tag.name and sibling_tag.name == "titl... | python | def title_tag_inspected(tag, parent_tag_name=None, p_parent_tag_name=None, direct_sibling_only=False):
"""Extract the title tag and sometimes inspect its parents"""
title_tag = None
if direct_sibling_only is True:
for sibling_tag in tag:
if sibling_tag.name and sibling_tag.name == "titl... | [
"def",
"title_tag_inspected",
"(",
"tag",
",",
"parent_tag_name",
"=",
"None",
",",
"p_parent_tag_name",
"=",
"None",
",",
"direct_sibling_only",
"=",
"False",
")",
":",
"title_tag",
"=",
"None",
"if",
"direct_sibling_only",
"is",
"True",
":",
"for",
"sibling_ta... | Extract the title tag and sometimes inspect its parents | [
"Extract",
"the",
"title",
"tag",
"and",
"sometimes",
"inspect",
"its",
"parents"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2002-L2021 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | title_text | def title_text(tag, parent_tag_name=None, p_parent_tag_name=None, direct_sibling_only=False):
"""Extract the text of a title tag and sometimes inspect its parents"""
title = None
title_tag = title_tag_inspected(tag, parent_tag_name, p_parent_tag_name, direct_sibling_only)
if title_tag:
title =... | python | def title_text(tag, parent_tag_name=None, p_parent_tag_name=None, direct_sibling_only=False):
"""Extract the text of a title tag and sometimes inspect its parents"""
title = None
title_tag = title_tag_inspected(tag, parent_tag_name, p_parent_tag_name, direct_sibling_only)
if title_tag:
title =... | [
"def",
"title_text",
"(",
"tag",
",",
"parent_tag_name",
"=",
"None",
",",
"p_parent_tag_name",
"=",
"None",
",",
"direct_sibling_only",
"=",
"False",
")",
":",
"title",
"=",
"None",
"title_tag",
"=",
"title_tag_inspected",
"(",
"tag",
",",
"parent_tag_name",
... | Extract the text of a title tag and sometimes inspect its parents | [
"Extract",
"the",
"text",
"of",
"a",
"title",
"tag",
"and",
"sometimes",
"inspect",
"its",
"parents"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2023-L2031 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | boxed_text_to_image_block | def boxed_text_to_image_block(tag):
"covert boxed-text to an image block containing an inline-graphic"
tag_block = OrderedDict()
image_content = body_block_image_content(first(raw_parser.inline_graphic(tag)))
tag_block["type"] = "image"
set_if_value(tag_block, "doi", doi_uri_to_doi(object_id_doi(tag... | python | def boxed_text_to_image_block(tag):
"covert boxed-text to an image block containing an inline-graphic"
tag_block = OrderedDict()
image_content = body_block_image_content(first(raw_parser.inline_graphic(tag)))
tag_block["type"] = "image"
set_if_value(tag_block, "doi", doi_uri_to_doi(object_id_doi(tag... | [
"def",
"boxed_text_to_image_block",
"(",
"tag",
")",
":",
"tag_block",
"=",
"OrderedDict",
"(",
")",
"image_content",
"=",
"body_block_image_content",
"(",
"first",
"(",
"raw_parser",
".",
"inline_graphic",
"(",
"tag",
")",
")",
")",
"tag_block",
"[",
"\"type\""... | covert boxed-text to an image block containing an inline-graphic | [
"covert",
"boxed",
"-",
"text",
"to",
"an",
"image",
"block",
"containing",
"an",
"inline",
"-",
"graphic"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2077-L2092 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_json | def body_json(soup, base_url=None):
""" Get body json and then alter it with section wrapping and removing boxed-text """
body_content = body(soup, remove_key_info_box=True, base_url=base_url)
# Wrap in a section if the first block is not a section
if (body_content and len(body_content) > 0 and "type" i... | python | def body_json(soup, base_url=None):
""" Get body json and then alter it with section wrapping and removing boxed-text """
body_content = body(soup, remove_key_info_box=True, base_url=base_url)
# Wrap in a section if the first block is not a section
if (body_content and len(body_content) > 0 and "type" i... | [
"def",
"body_json",
"(",
"soup",
",",
"base_url",
"=",
"None",
")",
":",
"body_content",
"=",
"body",
"(",
"soup",
",",
"remove_key_info_box",
"=",
"True",
",",
"base_url",
"=",
"base_url",
")",
"# Wrap in a section if the first block is not a section",
"if",
"(",... | Get body json and then alter it with section wrapping and removing boxed-text | [
"Get",
"body",
"json",
"and",
"then",
"alter",
"it",
"with",
"section",
"wrapping",
"and",
"removing",
"boxed",
"-",
"text"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2108-L2126 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_block_content_render | def body_block_content_render(tag, recursive=False, base_url=None):
"""
Render the tag as body content and call recursively if
the tag has child tags
"""
block_content_list = []
tag_content = OrderedDict()
if tag.name == "p":
for block_content in body_block_paragraph_render(tag, bas... | python | def body_block_content_render(tag, recursive=False, base_url=None):
"""
Render the tag as body content and call recursively if
the tag has child tags
"""
block_content_list = []
tag_content = OrderedDict()
if tag.name == "p":
for block_content in body_block_paragraph_render(tag, bas... | [
"def",
"body_block_content_render",
"(",
"tag",
",",
"recursive",
"=",
"False",
",",
"base_url",
"=",
"None",
")",
":",
"block_content_list",
"=",
"[",
"]",
"tag_content",
"=",
"OrderedDict",
"(",
")",
"if",
"tag",
".",
"name",
"==",
"\"p\"",
":",
"for",
... | Render the tag as body content and call recursively if
the tag has child tags | [
"Render",
"the",
"tag",
"as",
"body",
"content",
"and",
"call",
"recursively",
"if",
"the",
"tag",
"has",
"child",
"tags"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2175-L2232 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_block_paragraph_render | def body_block_paragraph_render(p_tag, html_flag=True, base_url=None):
"""
paragraphs may wrap some other body block content
this is separated out so it can be called from more than one place
"""
# Configure the XML to HTML conversion preference for shorthand use below
convert = lambda xml_strin... | python | def body_block_paragraph_render(p_tag, html_flag=True, base_url=None):
"""
paragraphs may wrap some other body block content
this is separated out so it can be called from more than one place
"""
# Configure the XML to HTML conversion preference for shorthand use below
convert = lambda xml_strin... | [
"def",
"body_block_paragraph_render",
"(",
"p_tag",
",",
"html_flag",
"=",
"True",
",",
"base_url",
"=",
"None",
")",
":",
"# Configure the XML to HTML conversion preference for shorthand use below",
"convert",
"=",
"lambda",
"xml_string",
":",
"xml_to_html",
"(",
"html_f... | paragraphs may wrap some other body block content
this is separated out so it can be called from more than one place | [
"paragraphs",
"may",
"wrap",
"some",
"other",
"body",
"block",
"content",
"this",
"is",
"separated",
"out",
"so",
"it",
"can",
"be",
"called",
"from",
"more",
"than",
"one",
"place"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2234-L2271 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_block_caption_render | def body_block_caption_render(caption_tags, base_url=None):
"""fig and media tag captions are similar so use this common function"""
caption_content = []
supplementary_material_tags = []
for block_tag in remove_doi_paragraph(caption_tags):
# Note then skip p tags with supplementary-material ins... | python | def body_block_caption_render(caption_tags, base_url=None):
"""fig and media tag captions are similar so use this common function"""
caption_content = []
supplementary_material_tags = []
for block_tag in remove_doi_paragraph(caption_tags):
# Note then skip p tags with supplementary-material ins... | [
"def",
"body_block_caption_render",
"(",
"caption_tags",
",",
"base_url",
"=",
"None",
")",
":",
"caption_content",
"=",
"[",
"]",
"supplementary_material_tags",
"=",
"[",
"]",
"for",
"block_tag",
"in",
"remove_doi_paragraph",
"(",
"caption_tags",
")",
":",
"# Not... | fig and media tag captions are similar so use this common function | [
"fig",
"and",
"media",
"tag",
"captions",
"are",
"similar",
"so",
"use",
"this",
"common",
"function"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2273-L2290 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_block_supplementary_material_render | def body_block_supplementary_material_render(supp_tags, base_url=None):
"""fig and media tag caption may have supplementary material"""
source_data = []
for supp_tag in supp_tags:
for block_content in body_block_content_render(supp_tag, base_url=base_url):
if block_content != {}:
... | python | def body_block_supplementary_material_render(supp_tags, base_url=None):
"""fig and media tag caption may have supplementary material"""
source_data = []
for supp_tag in supp_tags:
for block_content in body_block_content_render(supp_tag, base_url=base_url):
if block_content != {}:
... | [
"def",
"body_block_supplementary_material_render",
"(",
"supp_tags",
",",
"base_url",
"=",
"None",
")",
":",
"source_data",
"=",
"[",
"]",
"for",
"supp_tag",
"in",
"supp_tags",
":",
"for",
"block_content",
"in",
"body_block_content_render",
"(",
"supp_tag",
",",
"... | fig and media tag caption may have supplementary material | [
"fig",
"and",
"media",
"tag",
"caption",
"may",
"have",
"supplementary",
"material"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2292-L2301 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_block_paragraph_content | def body_block_paragraph_content(text):
"for formatting of simple paragraphs of text only, and check if it is all whitespace"
tag_content = OrderedDict()
if text and text != '':
tag_content["type"] = "paragraph"
tag_content["text"] = clean_whitespace(text)
return tag_content | python | def body_block_paragraph_content(text):
"for formatting of simple paragraphs of text only, and check if it is all whitespace"
tag_content = OrderedDict()
if text and text != '':
tag_content["type"] = "paragraph"
tag_content["text"] = clean_whitespace(text)
return tag_content | [
"def",
"body_block_paragraph_content",
"(",
"text",
")",
":",
"tag_content",
"=",
"OrderedDict",
"(",
")",
"if",
"text",
"and",
"text",
"!=",
"''",
":",
"tag_content",
"[",
"\"type\"",
"]",
"=",
"\"paragraph\"",
"tag_content",
"[",
"\"text\"",
"]",
"=",
"cle... | for formatting of simple paragraphs of text only, and check if it is all whitespace | [
"for",
"formatting",
"of",
"simple",
"paragraphs",
"of",
"text",
"only",
"and",
"check",
"if",
"it",
"is",
"all",
"whitespace"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2303-L2309 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_block_image_content | def body_block_image_content(tag):
"format a graphic or inline-graphic into a body block json format"
image_content = OrderedDict()
if tag:
copy_attribute(tag.attrs, 'xlink:href', image_content, 'uri')
if "uri" in image_content:
# todo!! alt
set_if_value(image_content... | python | def body_block_image_content(tag):
"format a graphic or inline-graphic into a body block json format"
image_content = OrderedDict()
if tag:
copy_attribute(tag.attrs, 'xlink:href', image_content, 'uri')
if "uri" in image_content:
# todo!! alt
set_if_value(image_content... | [
"def",
"body_block_image_content",
"(",
"tag",
")",
":",
"image_content",
"=",
"OrderedDict",
"(",
")",
"if",
"tag",
":",
"copy_attribute",
"(",
"tag",
".",
"attrs",
",",
"'xlink:href'",
",",
"image_content",
",",
"'uri'",
")",
"if",
"\"uri\"",
"in",
"image_... | format a graphic or inline-graphic into a body block json format | [
"format",
"a",
"graphic",
"or",
"inline",
"-",
"graphic",
"into",
"a",
"body",
"block",
"json",
"format"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2311-L2319 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_block_title_label_caption | def body_block_title_label_caption(tag_content, title_value, label_value,
caption_content, set_caption=True, prefer_title=False, prefer_label=False):
"""set the title, label and caption values in a consistent way
set_caption: insert a "caption" field
prefer_title: when on... | python | def body_block_title_label_caption(tag_content, title_value, label_value,
caption_content, set_caption=True, prefer_title=False, prefer_label=False):
"""set the title, label and caption values in a consistent way
set_caption: insert a "caption" field
prefer_title: when on... | [
"def",
"body_block_title_label_caption",
"(",
"tag_content",
",",
"title_value",
",",
"label_value",
",",
"caption_content",
",",
"set_caption",
"=",
"True",
",",
"prefer_title",
"=",
"False",
",",
"prefer_label",
"=",
"False",
")",
":",
"set_if_value",
"(",
"tag_... | set the title, label and caption values in a consistent way
set_caption: insert a "caption" field
prefer_title: when only one value is available, set title rather than label. If False, set label rather than title | [
"set",
"the",
"title",
"label",
"and",
"caption",
"values",
"in",
"a",
"consistent",
"way"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2321-L2338 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_block_attribution | def body_block_attribution(tag):
"extract the attribution content for figures, tables, videos"
attributions = []
if raw_parser.attrib(tag):
for attrib_tag in raw_parser.attrib(tag):
attributions.append(node_contents_str(attrib_tag))
if raw_parser.permissions(tag):
# concatena... | python | def body_block_attribution(tag):
"extract the attribution content for figures, tables, videos"
attributions = []
if raw_parser.attrib(tag):
for attrib_tag in raw_parser.attrib(tag):
attributions.append(node_contents_str(attrib_tag))
if raw_parser.permissions(tag):
# concatena... | [
"def",
"body_block_attribution",
"(",
"tag",
")",
":",
"attributions",
"=",
"[",
"]",
"if",
"raw_parser",
".",
"attrib",
"(",
"tag",
")",
":",
"for",
"attrib_tag",
"in",
"raw_parser",
".",
"attrib",
"(",
"tag",
")",
":",
"attributions",
".",
"append",
"(... | extract the attribution content for figures, tables, videos | [
"extract",
"the",
"attribution",
"content",
"for",
"figures",
"tables",
"videos"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2340-L2360 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | body_blocks | def body_blocks(soup):
"""
Note: for some reason this works and few other attempted methods work
Search for certain node types, find the first nodes siblings of the same type
Add the first sibling and the other siblings to a list and return them
"""
nodenames = body_block_nodenames()
body_b... | python | def body_blocks(soup):
"""
Note: for some reason this works and few other attempted methods work
Search for certain node types, find the first nodes siblings of the same type
Add the first sibling and the other siblings to a list and return them
"""
nodenames = body_block_nodenames()
body_b... | [
"def",
"body_blocks",
"(",
"soup",
")",
":",
"nodenames",
"=",
"body_block_nodenames",
"(",
")",
"body_block_tags",
"=",
"[",
"]",
"if",
"not",
"soup",
":",
"return",
"body_block_tags",
"first_sibling_node",
"=",
"firstnn",
"(",
"soup",
".",
"find_all",
"(",
... | Note: for some reason this works and few other attempted methods work
Search for certain node types, find the first nodes siblings of the same type
Add the first sibling and the other siblings to a list and return them | [
"Note",
":",
"for",
"some",
"reason",
"this",
"works",
"and",
"few",
"other",
"attempted",
"methods",
"work",
"Search",
"for",
"certain",
"node",
"types",
"find",
"the",
"first",
"nodes",
"siblings",
"of",
"the",
"same",
"type",
"Add",
"the",
"first",
"sib... | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2655-L2681 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | abstract_json | def abstract_json(soup):
"""abstract in article json format"""
abstract_tags = raw_parser.abstract(soup)
abstract_json = None
for tag in abstract_tags:
if tag.get("abstract-type") is None:
abstract_json = render_abstract_json(tag)
return abstract_json | python | def abstract_json(soup):
"""abstract in article json format"""
abstract_tags = raw_parser.abstract(soup)
abstract_json = None
for tag in abstract_tags:
if tag.get("abstract-type") is None:
abstract_json = render_abstract_json(tag)
return abstract_json | [
"def",
"abstract_json",
"(",
"soup",
")",
":",
"abstract_tags",
"=",
"raw_parser",
".",
"abstract",
"(",
"soup",
")",
"abstract_json",
"=",
"None",
"for",
"tag",
"in",
"abstract_tags",
":",
"if",
"tag",
".",
"get",
"(",
"\"abstract-type\"",
")",
"is",
"Non... | abstract in article json format | [
"abstract",
"in",
"article",
"json",
"format"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2763-L2770 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | digest_json | def digest_json(soup):
"""digest in article json format"""
abstract_tags = raw_parser.abstract(soup, abstract_type="executive-summary")
abstract_json = None
for tag in abstract_tags:
abstract_json = render_abstract_json(tag)
return abstract_json | python | def digest_json(soup):
"""digest in article json format"""
abstract_tags = raw_parser.abstract(soup, abstract_type="executive-summary")
abstract_json = None
for tag in abstract_tags:
abstract_json = render_abstract_json(tag)
return abstract_json | [
"def",
"digest_json",
"(",
"soup",
")",
":",
"abstract_tags",
"=",
"raw_parser",
".",
"abstract",
"(",
"soup",
",",
"abstract_type",
"=",
"\"executive-summary\"",
")",
"abstract_json",
"=",
"None",
"for",
"tag",
"in",
"abstract_tags",
":",
"abstract_json",
"=",
... | digest in article json format | [
"digest",
"in",
"article",
"json",
"format"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2773-L2779 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | author_affiliations | def author_affiliations(author, html_flag=True):
"""compile author affiliations for json output"""
# Configure the XML to HTML conversion preference for shorthand use below
convert = lambda xml_string: xml_to_html(html_flag, xml_string)
affilations = []
if author.get("affiliations"):
for ... | python | def author_affiliations(author, html_flag=True):
"""compile author affiliations for json output"""
# Configure the XML to HTML conversion preference for shorthand use below
convert = lambda xml_string: xml_to_html(html_flag, xml_string)
affilations = []
if author.get("affiliations"):
for ... | [
"def",
"author_affiliations",
"(",
"author",
",",
"html_flag",
"=",
"True",
")",
":",
"# Configure the XML to HTML conversion preference for shorthand use below",
"convert",
"=",
"lambda",
"xml_string",
":",
"xml_to_html",
"(",
"html_flag",
",",
"xml_string",
")",
"affila... | compile author affiliations for json output | [
"compile",
"author",
"affiliations",
"for",
"json",
"output"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2782-L2825 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | author_json_details | def author_json_details(author, author_json, contributions, correspondence,
competing_interests, equal_contributions_map, present_address_data,
foot_notes_data, html_flag=True):
# Configure the XML to HTML conversion preference for shorthand use below
convert = la... | python | def author_json_details(author, author_json, contributions, correspondence,
competing_interests, equal_contributions_map, present_address_data,
foot_notes_data, html_flag=True):
# Configure the XML to HTML conversion preference for shorthand use below
convert = la... | [
"def",
"author_json_details",
"(",
"author",
",",
"author_json",
",",
"contributions",
",",
"correspondence",
",",
"competing_interests",
",",
"equal_contributions_map",
",",
"present_address_data",
",",
"foot_notes_data",
",",
"html_flag",
"=",
"True",
")",
":",
"# C... | add more author json | [
"add",
"more",
"author",
"json"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L2963-L3002 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | collab_to_group_author_key_map | def collab_to_group_author_key_map(authors):
"""compile a map of author collab to group-author-key"""
collab_map = {}
for author in authors:
if author.get("collab"):
collab_map[author.get("collab")] = author.get("group-author-key")
return collab_map | python | def collab_to_group_author_key_map(authors):
"""compile a map of author collab to group-author-key"""
collab_map = {}
for author in authors:
if author.get("collab"):
collab_map[author.get("collab")] = author.get("group-author-key")
return collab_map | [
"def",
"collab_to_group_author_key_map",
"(",
"authors",
")",
":",
"collab_map",
"=",
"{",
"}",
"for",
"author",
"in",
"authors",
":",
"if",
"author",
".",
"get",
"(",
"\"collab\"",
")",
":",
"collab_map",
"[",
"author",
".",
"get",
"(",
"\"collab\"",
")",... | compile a map of author collab to group-author-key | [
"compile",
"a",
"map",
"of",
"author",
"collab",
"to",
"group",
"-",
"author",
"-",
"key"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3049-L3055 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | map_equal_contributions | def map_equal_contributions(contributors):
"""assign numeric values to each unique equal-contrib id"""
equal_contribution_map = {}
equal_contribution_keys = []
for contributor in contributors:
if contributor.get("references") and "equal-contrib" in contributor.get("references"):
for ... | python | def map_equal_contributions(contributors):
"""assign numeric values to each unique equal-contrib id"""
equal_contribution_map = {}
equal_contribution_keys = []
for contributor in contributors:
if contributor.get("references") and "equal-contrib" in contributor.get("references"):
for ... | [
"def",
"map_equal_contributions",
"(",
"contributors",
")",
":",
"equal_contribution_map",
"=",
"{",
"}",
"equal_contribution_keys",
"=",
"[",
"]",
"for",
"contributor",
"in",
"contributors",
":",
"if",
"contributor",
".",
"get",
"(",
"\"references\"",
")",
"and",... | assign numeric values to each unique equal-contrib id | [
"assign",
"numeric",
"values",
"to",
"each",
"unique",
"equal",
"-",
"contrib",
"id"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3057-L3071 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | authors_json | def authors_json(soup):
"""authors list in article json format"""
authors_json_data = []
contributors_data = contributors(soup, "full")
author_contributions_data = author_contributions(soup, None)
author_competing_interests_data = competing_interests(soup, None)
author_correspondence_data = full... | python | def authors_json(soup):
"""authors list in article json format"""
authors_json_data = []
contributors_data = contributors(soup, "full")
author_contributions_data = author_contributions(soup, None)
author_competing_interests_data = competing_interests(soup, None)
author_correspondence_data = full... | [
"def",
"authors_json",
"(",
"soup",
")",
":",
"authors_json_data",
"=",
"[",
"]",
"contributors_data",
"=",
"contributors",
"(",
"soup",
",",
"\"full\"",
")",
"author_contributions_data",
"=",
"author_contributions",
"(",
"soup",
",",
"None",
")",
"author_competin... | authors list in article json format | [
"authors",
"list",
"in",
"article",
"json",
"format"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3088-L3141 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | author_line | def author_line(soup):
"""take preferred names from authors json and format them into an author line"""
author_line = None
authors_json_data = authors_json(soup)
author_names = extract_author_line_names(authors_json_data)
if len(author_names) > 0:
author_line = format_author_line(author_name... | python | def author_line(soup):
"""take preferred names from authors json and format them into an author line"""
author_line = None
authors_json_data = authors_json(soup)
author_names = extract_author_line_names(authors_json_data)
if len(author_names) > 0:
author_line = format_author_line(author_name... | [
"def",
"author_line",
"(",
"soup",
")",
":",
"author_line",
"=",
"None",
"authors_json_data",
"=",
"authors_json",
"(",
"soup",
")",
"author_names",
"=",
"extract_author_line_names",
"(",
"authors_json_data",
")",
"if",
"len",
"(",
"author_names",
")",
">",
"0",... | take preferred names from authors json and format them into an author line | [
"take",
"preferred",
"names",
"from",
"authors",
"json",
"and",
"format",
"them",
"into",
"an",
"author",
"line"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3143-L3150 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | format_author_line | def format_author_line(author_names):
"""authorLine format depends on if there is 1, 2 or more than 2 authors"""
author_line = None
if not author_names:
return author_line
if len(author_names) <= 2:
author_line = ", ".join(author_names)
elif len(author_names) > 2:
author_line... | python | def format_author_line(author_names):
"""authorLine format depends on if there is 1, 2 or more than 2 authors"""
author_line = None
if not author_names:
return author_line
if len(author_names) <= 2:
author_line = ", ".join(author_names)
elif len(author_names) > 2:
author_line... | [
"def",
"format_author_line",
"(",
"author_names",
")",
":",
"author_line",
"=",
"None",
"if",
"not",
"author_names",
":",
"return",
"author_line",
"if",
"len",
"(",
"author_names",
")",
"<=",
"2",
":",
"author_line",
"=",
"\", \"",
".",
"join",
"(",
"author_... | authorLine format depends on if there is 1, 2 or more than 2 authors | [
"authorLine",
"format",
"depends",
"on",
"if",
"there",
"is",
"1",
"2",
"or",
"more",
"than",
"2",
"authors"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3165-L3174 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | references_date | def references_date(year=None):
"Handle year value parsing for some edge cases"
date = None
discriminator = None
in_press = None
if year and "in press" in year.lower().strip():
in_press = True
elif year and re.match("^[0-9]+$", year):
date = year
elif year:
discrimina... | python | def references_date(year=None):
"Handle year value parsing for some edge cases"
date = None
discriminator = None
in_press = None
if year and "in press" in year.lower().strip():
in_press = True
elif year and re.match("^[0-9]+$", year):
date = year
elif year:
discrimina... | [
"def",
"references_date",
"(",
"year",
"=",
"None",
")",
":",
"date",
"=",
"None",
"discriminator",
"=",
"None",
"in_press",
"=",
"None",
"if",
"year",
"and",
"\"in press\"",
"in",
"year",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
":",
"in_press"... | Handle year value parsing for some edge cases | [
"Handle",
"year",
"value",
"parsing",
"for",
"some",
"edge",
"cases"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3210-L3226 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | references_json_authors | def references_json_authors(ref_authors, ref_content):
"build the authors for references json here for testability"
all_authors = references_authors(ref_authors)
if all_authors != {}:
if ref_content.get("type") in ["conference-proceeding", "journal", "other",
... | python | def references_json_authors(ref_authors, ref_content):
"build the authors for references json here for testability"
all_authors = references_authors(ref_authors)
if all_authors != {}:
if ref_content.get("type") in ["conference-proceeding", "journal", "other",
... | [
"def",
"references_json_authors",
"(",
"ref_authors",
",",
"ref_content",
")",
":",
"all_authors",
"=",
"references_authors",
"(",
"ref_authors",
")",
"if",
"all_authors",
"!=",
"{",
"}",
":",
"if",
"ref_content",
".",
"get",
"(",
"\"type\"",
")",
"in",
"[",
... | build the authors for references json here for testability | [
"build",
"the",
"authors",
"for",
"references",
"json",
"here",
"for",
"testability"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3256-L3285 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | convert_references_json | def convert_references_json(ref_content, soup=None):
"Check for references that will not pass schema validation, fix or convert them to unknown"
# Convert reference to unkonwn if still missing important values
if (
(ref_content.get("type") == "other")
or
(ref_content.get("type") == ... | python | def convert_references_json(ref_content, soup=None):
"Check for references that will not pass schema validation, fix or convert them to unknown"
# Convert reference to unkonwn if still missing important values
if (
(ref_content.get("type") == "other")
or
(ref_content.get("type") == ... | [
"def",
"convert_references_json",
"(",
"ref_content",
",",
"soup",
"=",
"None",
")",
":",
"# Convert reference to unkonwn if still missing important values",
"if",
"(",
"(",
"ref_content",
".",
"get",
"(",
"\"type\"",
")",
"==",
"\"other\"",
")",
"or",
"(",
"ref_con... | Check for references that will not pass schema validation, fix or convert them to unknown | [
"Check",
"for",
"references",
"that",
"will",
"not",
"pass",
"schema",
"validation",
"fix",
"or",
"convert",
"them",
"to",
"unknown"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3480-L3507 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | references_json_unknown_details | def references_json_unknown_details(ref_content, soup=None):
"Extract detail value for references of type unknown"
details = ""
# Try adding pages values first
if "pages" in ref_content:
if "range" in ref_content["pages"]:
details += ref_content["pages"]["range"]
else:
... | python | def references_json_unknown_details(ref_content, soup=None):
"Extract detail value for references of type unknown"
details = ""
# Try adding pages values first
if "pages" in ref_content:
if "range" in ref_content["pages"]:
details += ref_content["pages"]["range"]
else:
... | [
"def",
"references_json_unknown_details",
"(",
"ref_content",
",",
"soup",
"=",
"None",
")",
":",
"details",
"=",
"\"\"",
"# Try adding pages values first",
"if",
"\"pages\"",
"in",
"ref_content",
":",
"if",
"\"range\"",
"in",
"ref_content",
"[",
"\"pages\"",
"]",
... | Extract detail value for references of type unknown | [
"Extract",
"detail",
"value",
"for",
"references",
"of",
"type",
"unknown"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3540-L3569 | train |
elifesciences/elife-tools | elifetools/parseJATS.py | unwrap_appendix_box | def unwrap_appendix_box(json_content):
"""for use in removing unwanted boxed-content from appendices json"""
if json_content.get("content") and len(json_content["content"]) > 0:
first_block = json_content["content"][0]
if (first_block.get("type")
and first_block.get("type") == "box"
... | python | def unwrap_appendix_box(json_content):
"""for use in removing unwanted boxed-content from appendices json"""
if json_content.get("content") and len(json_content["content"]) > 0:
first_block = json_content["content"][0]
if (first_block.get("type")
and first_block.get("type") == "box"
... | [
"def",
"unwrap_appendix_box",
"(",
"json_content",
")",
":",
"if",
"json_content",
".",
"get",
"(",
"\"content\"",
")",
"and",
"len",
"(",
"json_content",
"[",
"\"content\"",
"]",
")",
">",
"0",
":",
"first_block",
"=",
"json_content",
"[",
"\"content\"",
"]... | for use in removing unwanted boxed-content from appendices json | [
"for",
"use",
"in",
"removing",
"unwanted",
"boxed",
"-",
"content",
"from",
"appendices",
"json"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L3593-L3603 | train |
canonical-ols/acceptable | acceptable/_build_doubles.py | extract_schemas_from_file | def extract_schemas_from_file(source_path):
"""Extract schemas from 'source_path'.
:returns: a list of ViewSchema objects on success, None if no schemas
could be extracted.
"""
logging.info("Extracting schemas from %s", source_path)
try:
with open(source_path, 'r') as source_file:
... | python | def extract_schemas_from_file(source_path):
"""Extract schemas from 'source_path'.
:returns: a list of ViewSchema objects on success, None if no schemas
could be extracted.
"""
logging.info("Extracting schemas from %s", source_path)
try:
with open(source_path, 'r') as source_file:
... | [
"def",
"extract_schemas_from_file",
"(",
"source_path",
")",
":",
"logging",
".",
"info",
"(",
"\"Extracting schemas from %s\"",
",",
"source_path",
")",
"try",
":",
"with",
"open",
"(",
"source_path",
",",
"'r'",
")",
"as",
"source_file",
":",
"source",
"=",
... | Extract schemas from 'source_path'.
:returns: a list of ViewSchema objects on success, None if no schemas
could be extracted. | [
"Extract",
"schemas",
"from",
"source_path",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_build_doubles.py#L129-L151 | train |
canonical-ols/acceptable | acceptable/_build_doubles.py | _get_simple_assignments | def _get_simple_assignments(tree):
"""Get simple assignments from node tree."""
result = {}
for node in ast.walk(tree):
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name):
result[target.id] = node.value
ret... | python | def _get_simple_assignments(tree):
"""Get simple assignments from node tree."""
result = {}
for node in ast.walk(tree):
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name):
result[target.id] = node.value
ret... | [
"def",
"_get_simple_assignments",
"(",
"tree",
")",
":",
"result",
"=",
"{",
"}",
"for",
"node",
"in",
"ast",
".",
"walk",
"(",
"tree",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"ast",
".",
"Assign",
")",
":",
"for",
"target",
"in",
"node",
"... | Get simple assignments from node tree. | [
"Get",
"simple",
"assignments",
"from",
"node",
"tree",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_build_doubles.py#L154-L162 | train |
canonical-ols/acceptable | acceptable/_build_doubles.py | extract_schemas_from_source | def extract_schemas_from_source(source, filename='<unknown>'):
"""Extract schemas from 'source'.
The 'source' parameter must be a string, and should be valid python
source.
If 'source' is not valid python source, a SyntaxError will be raised.
:returns: a list of ViewSchema objects.
"""
# ... | python | def extract_schemas_from_source(source, filename='<unknown>'):
"""Extract schemas from 'source'.
The 'source' parameter must be a string, and should be valid python
source.
If 'source' is not valid python source, a SyntaxError will be raised.
:returns: a list of ViewSchema objects.
"""
# ... | [
"def",
"extract_schemas_from_source",
"(",
"source",
",",
"filename",
"=",
"'<unknown>'",
")",
":",
"# Track which acceptable services have been configured.",
"acceptable_services",
"=",
"set",
"(",
")",
"# Track which acceptable views have been configured:",
"acceptable_views",
... | Extract schemas from 'source'.
The 'source' parameter must be a string, and should be valid python
source.
If 'source' is not valid python source, a SyntaxError will be raised.
:returns: a list of ViewSchema objects. | [
"Extract",
"schemas",
"from",
"source",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_build_doubles.py#L177-L289 | train |
canonical-ols/acceptable | acceptable/_build_doubles.py | render_value | def render_value(value):
"""Render a value, ensuring that any nested dicts are sorted by key."""
if isinstance(value, list):
return '[' + ', '.join(render_value(v) for v in value) + ']'
elif isinstance(value, dict):
return (
'{' +
', '.join('{k!r}: {v}'.format(
... | python | def render_value(value):
"""Render a value, ensuring that any nested dicts are sorted by key."""
if isinstance(value, list):
return '[' + ', '.join(render_value(v) for v in value) + ']'
elif isinstance(value, dict):
return (
'{' +
', '.join('{k!r}: {v}'.format(
... | [
"def",
"render_value",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"return",
"'['",
"+",
"', '",
".",
"join",
"(",
"render_value",
"(",
"v",
")",
"for",
"v",
"in",
"value",
")",
"+",
"']'",
"elif",
"isinstance",
... | Render a value, ensuring that any nested dicts are sorted by key. | [
"Render",
"a",
"value",
"ensuring",
"that",
"any",
"nested",
"dicts",
"are",
"sorted",
"by",
"key",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_build_doubles.py#L292-L303 | train |
canonical-ols/acceptable | acceptable/_build_doubles.py | write_service_double_file | def write_service_double_file(target_root, service_name, rendered):
"""Render syntactically valid python service double code."""
target_path = os.path.join(
target_root,
'snapstore_schemas', 'service_doubles', '%s.py' % service_name
)
with open(target_path, 'w') as target_file:
t... | python | def write_service_double_file(target_root, service_name, rendered):
"""Render syntactically valid python service double code."""
target_path = os.path.join(
target_root,
'snapstore_schemas', 'service_doubles', '%s.py' % service_name
)
with open(target_path, 'w') as target_file:
t... | [
"def",
"write_service_double_file",
"(",
"target_root",
",",
"service_name",
",",
"rendered",
")",
":",
"target_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"target_root",
",",
"'snapstore_schemas'",
",",
"'service_doubles'",
",",
"'%s.py'",
"%",
"service_name... | Render syntactically valid python service double code. | [
"Render",
"syntactically",
"valid",
"python",
"service",
"double",
"code",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_build_doubles.py#L346-L353 | train |
canonical-ols/acceptable | acceptable/util.py | clean_docstring | def clean_docstring(docstring):
"""Dedent docstring, special casing the first line."""
docstring = docstring.strip()
if '\n' in docstring:
# multiline docstring
if docstring[0].isspace():
# whole docstring is indented
return textwrap.dedent(docstring)
else:
... | python | def clean_docstring(docstring):
"""Dedent docstring, special casing the first line."""
docstring = docstring.strip()
if '\n' in docstring:
# multiline docstring
if docstring[0].isspace():
# whole docstring is indented
return textwrap.dedent(docstring)
else:
... | [
"def",
"clean_docstring",
"(",
"docstring",
")",
":",
"docstring",
"=",
"docstring",
".",
"strip",
"(",
")",
"if",
"'\\n'",
"in",
"docstring",
":",
"# multiline docstring",
"if",
"docstring",
"[",
"0",
"]",
".",
"isspace",
"(",
")",
":",
"# whole docstring i... | Dedent docstring, special casing the first line. | [
"Dedent",
"docstring",
"special",
"casing",
"the",
"first",
"line",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/util.py#L24-L36 | train |
canonical-ols/acceptable | acceptable/util.py | _sort_schema | def _sort_schema(schema):
"""Recursively sorts a JSON schema by dict key."""
if isinstance(schema, dict):
for k, v in sorted(schema.items()):
if isinstance(v, dict):
yield k, OrderedDict(_sort_schema(v))
elif isinstance(v, list):
yield k, list(_so... | python | def _sort_schema(schema):
"""Recursively sorts a JSON schema by dict key."""
if isinstance(schema, dict):
for k, v in sorted(schema.items()):
if isinstance(v, dict):
yield k, OrderedDict(_sort_schema(v))
elif isinstance(v, list):
yield k, list(_so... | [
"def",
"_sort_schema",
"(",
"schema",
")",
":",
"if",
"isinstance",
"(",
"schema",
",",
"dict",
")",
":",
"for",
"k",
",",
"v",
"in",
"sorted",
"(",
"schema",
".",
"items",
"(",
")",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
... | Recursively sorts a JSON schema by dict key. | [
"Recursively",
"sorts",
"a",
"JSON",
"schema",
"by",
"dict",
"key",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/util.py#L39-L59 | train |
canonical-ols/acceptable | acceptable/djangoutil.py | urlmap | def urlmap(patterns):
"""Recursively build a map of (group, name) => url patterns.
Group is either the resolver namespace or app name for the url config.
The urls are joined with any prefixes, and cleaned up of extraneous regex
specific syntax."""
for pattern in patterns:
group = getattr(p... | python | def urlmap(patterns):
"""Recursively build a map of (group, name) => url patterns.
Group is either the resolver namespace or app name for the url config.
The urls are joined with any prefixes, and cleaned up of extraneous regex
specific syntax."""
for pattern in patterns:
group = getattr(p... | [
"def",
"urlmap",
"(",
"patterns",
")",
":",
"for",
"pattern",
"in",
"patterns",
":",
"group",
"=",
"getattr",
"(",
"pattern",
",",
"'namespace'",
",",
"None",
")",
"if",
"group",
"is",
"None",
":",
"group",
"=",
"getattr",
"(",
"pattern",
",",
"'app_na... | Recursively build a map of (group, name) => url patterns.
Group is either the resolver namespace or app name for the url config.
The urls are joined with any prefixes, and cleaned up of extraneous regex
specific syntax. | [
"Recursively",
"build",
"a",
"map",
"of",
"(",
"group",
"name",
")",
"=",
">",
"url",
"patterns",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/djangoutil.py#L64-L81 | train |
canonical-ols/acceptable | acceptable/djangoutil.py | get_field_schema | def get_field_schema(name, field):
"""Returns a JSON Schema representation of a form field."""
field_schema = {
'type': 'string',
}
if field.label:
field_schema['title'] = str(field.label) # force translation
if field.help_text:
field_schema['description'] = str(field.help... | python | def get_field_schema(name, field):
"""Returns a JSON Schema representation of a form field."""
field_schema = {
'type': 'string',
}
if field.label:
field_schema['title'] = str(field.label) # force translation
if field.help_text:
field_schema['description'] = str(field.help... | [
"def",
"get_field_schema",
"(",
"name",
",",
"field",
")",
":",
"field_schema",
"=",
"{",
"'type'",
":",
"'string'",
",",
"}",
"if",
"field",
".",
"label",
":",
"field_schema",
"[",
"'title'",
"]",
"=",
"str",
"(",
"field",
".",
"label",
")",
"# force ... | Returns a JSON Schema representation of a form field. | [
"Returns",
"a",
"JSON",
"Schema",
"representation",
"of",
"a",
"form",
"field",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/djangoutil.py#L84-L127 | train |
canonical-ols/acceptable | acceptable/djangoutil.py | get_form_schema | def get_form_schema(form):
"""Return a JSON Schema object for a Django Form."""
schema = {
'type': 'object',
'properties': {},
}
for name, field in form.base_fields.items():
schema['properties'][name] = get_field_schema(name, field)
if field.required:
schema.... | python | def get_form_schema(form):
"""Return a JSON Schema object for a Django Form."""
schema = {
'type': 'object',
'properties': {},
}
for name, field in form.base_fields.items():
schema['properties'][name] = get_field_schema(name, field)
if field.required:
schema.... | [
"def",
"get_form_schema",
"(",
"form",
")",
":",
"schema",
"=",
"{",
"'type'",
":",
"'object'",
",",
"'properties'",
":",
"{",
"}",
",",
"}",
"for",
"name",
",",
"field",
"in",
"form",
".",
"base_fields",
".",
"items",
"(",
")",
":",
"schema",
"[",
... | Return a JSON Schema object for a Django Form. | [
"Return",
"a",
"JSON",
"Schema",
"object",
"for",
"a",
"Django",
"Form",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/djangoutil.py#L130-L142 | train |
canonical-ols/acceptable | acceptable/djangoutil.py | DjangoAPI.handler | def handler(self, handler_class):
"""Link to an API handler class (e.g. piston or DRF)."""
self.handler_class = handler_class
# we take the docstring from the handler class, not the methods
if self.docs is None and handler_class.__doc__:
self.docs = clean_docstring(handler_cl... | python | def handler(self, handler_class):
"""Link to an API handler class (e.g. piston or DRF)."""
self.handler_class = handler_class
# we take the docstring from the handler class, not the methods
if self.docs is None and handler_class.__doc__:
self.docs = clean_docstring(handler_cl... | [
"def",
"handler",
"(",
"self",
",",
"handler_class",
")",
":",
"self",
".",
"handler_class",
"=",
"handler_class",
"# we take the docstring from the handler class, not the methods",
"if",
"self",
".",
"docs",
"is",
"None",
"and",
"handler_class",
".",
"__doc__",
":",
... | Link to an API handler class (e.g. piston or DRF). | [
"Link",
"to",
"an",
"API",
"handler",
"class",
"(",
"e",
".",
"g",
".",
"piston",
"or",
"DRF",
")",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/djangoutil.py#L217-L223 | train |
elifesciences/elife-tools | elifetools/utils_html.py | xml_to_html | def xml_to_html(html_flag, xml_string, base_url=None):
"For formatting json output into HTML friendly format"
if not xml_string or not html_flag is True:
return xml_string
html_string = xml_string
html_string = remove_comment_tags(html_string)
# Escape unmatched angle brackets
if '<' in... | python | def xml_to_html(html_flag, xml_string, base_url=None):
"For formatting json output into HTML friendly format"
if not xml_string or not html_flag is True:
return xml_string
html_string = xml_string
html_string = remove_comment_tags(html_string)
# Escape unmatched angle brackets
if '<' in... | [
"def",
"xml_to_html",
"(",
"html_flag",
",",
"xml_string",
",",
"base_url",
"=",
"None",
")",
":",
"if",
"not",
"xml_string",
"or",
"not",
"html_flag",
"is",
"True",
":",
"return",
"xml_string",
"html_string",
"=",
"xml_string",
"html_string",
"=",
"remove_com... | For formatting json output into HTML friendly format | [
"For",
"formatting",
"json",
"output",
"into",
"HTML",
"friendly",
"format"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils_html.py#L5-L29 | train |
elifesciences/elife-tools | elifetools/utils_html.py | replace_simple_tags | def replace_simple_tags(s, from_tag='italic', to_tag='i', to_open_tag=None):
"""
Replace tags such as <italic> to <i>
This does not validate markup
"""
if to_open_tag:
s = s.replace('<' + from_tag + '>', to_open_tag)
elif to_tag:
s = s.replace('<' + from_tag + '>', '<' + to_tag +... | python | def replace_simple_tags(s, from_tag='italic', to_tag='i', to_open_tag=None):
"""
Replace tags such as <italic> to <i>
This does not validate markup
"""
if to_open_tag:
s = s.replace('<' + from_tag + '>', to_open_tag)
elif to_tag:
s = s.replace('<' + from_tag + '>', '<' + to_tag +... | [
"def",
"replace_simple_tags",
"(",
"s",
",",
"from_tag",
"=",
"'italic'",
",",
"to_tag",
"=",
"'i'",
",",
"to_open_tag",
"=",
"None",
")",
":",
"if",
"to_open_tag",
":",
"s",
"=",
"s",
".",
"replace",
"(",
"'<'",
"+",
"from_tag",
"+",
"'>'",
",",
"to... | Replace tags such as <italic> to <i>
This does not validate markup | [
"Replace",
"tags",
"such",
"as",
"<italic",
">",
"to",
"<i",
">",
"This",
"does",
"not",
"validate",
"markup"
] | 4b9e38cbe485c61a4ed7cbd8970c6b318334fd86 | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils_html.py#L70-L89 | train |
canonical-ols/acceptable | acceptable/_validation.py | validate_body | def validate_body(schema):
"""Validate the body of incoming requests for a flask view.
An example usage might look like this::
from snapstore_schemas import validate_body
@validate_body({
'type': 'array',
'items': {
'type': 'object',
'p... | python | def validate_body(schema):
"""Validate the body of incoming requests for a flask view.
An example usage might look like this::
from snapstore_schemas import validate_body
@validate_body({
'type': 'array',
'items': {
'type': 'object',
'p... | [
"def",
"validate_body",
"(",
"schema",
")",
":",
"location",
"=",
"get_callsite_location",
"(",
")",
"def",
"decorator",
"(",
"fn",
")",
":",
"validate_schema",
"(",
"schema",
")",
"wrapper",
"=",
"wrap_request",
"(",
"fn",
",",
"schema",
")",
"record_schema... | Validate the body of incoming requests for a flask view.
An example usage might look like this::
from snapstore_schemas import validate_body
@validate_body({
'type': 'array',
'items': {
'type': 'object',
'properties': {
... | [
"Validate",
"the",
"body",
"of",
"incoming",
"requests",
"for",
"a",
"flask",
"view",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_validation.py#L30-L81 | train |
canonical-ols/acceptable | acceptable/_validation.py | record_schemas | def record_schemas(
fn, wrapper, location, request_schema=None, response_schema=None):
"""Support extracting the schema from the decorated function."""
# have we already been decorated by an acceptable api call?
has_acceptable = hasattr(fn, '_acceptable_metadata')
if request_schema is not None:... | python | def record_schemas(
fn, wrapper, location, request_schema=None, response_schema=None):
"""Support extracting the schema from the decorated function."""
# have we already been decorated by an acceptable api call?
has_acceptable = hasattr(fn, '_acceptable_metadata')
if request_schema is not None:... | [
"def",
"record_schemas",
"(",
"fn",
",",
"wrapper",
",",
"location",
",",
"request_schema",
"=",
"None",
",",
"response_schema",
"=",
"None",
")",
":",
"# have we already been decorated by an acceptable api call?",
"has_acceptable",
"=",
"hasattr",
"(",
"fn",
",",
"... | Support extracting the schema from the decorated function. | [
"Support",
"extracting",
"the",
"schema",
"from",
"the",
"decorated",
"function",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_validation.py#L108-L128 | train |
canonical-ols/acceptable | acceptable/_validation.py | validate_output | def validate_output(schema):
"""Validate the body of a response from a flask view.
Like `validate_body`, this function compares a json document to a
jsonschema specification. However, this function applies the schema to the
view response.
Instead of the view returning a flask response object, it s... | python | def validate_output(schema):
"""Validate the body of a response from a flask view.
Like `validate_body`, this function compares a json document to a
jsonschema specification. However, this function applies the schema to the
view response.
Instead of the view returning a flask response object, it s... | [
"def",
"validate_output",
"(",
"schema",
")",
":",
"location",
"=",
"get_callsite_location",
"(",
")",
"def",
"decorator",
"(",
"fn",
")",
":",
"validate_schema",
"(",
"schema",
")",
"wrapper",
"=",
"wrap_response",
"(",
"fn",
",",
"schema",
")",
"record_sch... | Validate the body of a response from a flask view.
Like `validate_body`, this function compares a json document to a
jsonschema specification. However, this function applies the schema to the
view response.
Instead of the view returning a flask response object, it should instead
return a Python li... | [
"Validate",
"the",
"body",
"of",
"a",
"response",
"from",
"a",
"flask",
"view",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_validation.py#L131-L167 | train |
canonical-ols/acceptable | acceptable/_validation.py | validate | def validate(payload, schema):
"""Validate `payload` against `schema`, returning an error list.
jsonschema provides lots of information in it's errors, but it can be a bit
of work to extract all the information.
"""
v = jsonschema.Draft4Validator(
schema, format_checker=jsonschema.FormatChe... | python | def validate(payload, schema):
"""Validate `payload` against `schema`, returning an error list.
jsonschema provides lots of information in it's errors, but it can be a bit
of work to extract all the information.
"""
v = jsonschema.Draft4Validator(
schema, format_checker=jsonschema.FormatChe... | [
"def",
"validate",
"(",
"payload",
",",
"schema",
")",
":",
"v",
"=",
"jsonschema",
".",
"Draft4Validator",
"(",
"schema",
",",
"format_checker",
"=",
"jsonschema",
".",
"FormatChecker",
"(",
")",
")",
"error_list",
"=",
"[",
"]",
"for",
"error",
"in",
"... | Validate `payload` against `schema`, returning an error list.
jsonschema provides lots of information in it's errors, but it can be a bit
of work to extract all the information. | [
"Validate",
"payload",
"against",
"schema",
"returning",
"an",
"error",
"list",
"."
] | 6ccbe969078166a5315d857da38b59b43b29fadc | https://github.com/canonical-ols/acceptable/blob/6ccbe969078166a5315d857da38b59b43b29fadc/acceptable/_validation.py#L207-L220 | train |
lalinsky/python-phoenixdb | phoenixdb/__init__.py | connect | def connect(url, max_retries=None, **kwargs):
"""Connects to a Phoenix query server.
:param url:
URL to the Phoenix query server, e.g. ``http://localhost:8765/``
:param autocommit:
Switch the connection to autocommit mode.
:param readonly:
Switch the connection to readonly mod... | python | def connect(url, max_retries=None, **kwargs):
"""Connects to a Phoenix query server.
:param url:
URL to the Phoenix query server, e.g. ``http://localhost:8765/``
:param autocommit:
Switch the connection to autocommit mode.
:param readonly:
Switch the connection to readonly mod... | [
"def",
"connect",
"(",
"url",
",",
"max_retries",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"AvaticaClient",
"(",
"url",
",",
"max_retries",
"=",
"max_retries",
")",
"client",
".",
"connect",
"(",
")",
"return",
"Connection",
"(",
... | Connects to a Phoenix query server.
:param url:
URL to the Phoenix query server, e.g. ``http://localhost:8765/``
:param autocommit:
Switch the connection to autocommit mode.
:param readonly:
Switch the connection to readonly mode.
:param max_retries:
The maximum numbe... | [
"Connects",
"to",
"a",
"Phoenix",
"query",
"server",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/__init__.py#L44-L67 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.connect | def connect(self):
"""Opens a HTTP connection to the RPC server."""
logger.debug("Opening connection to %s:%s", self.url.hostname, self.url.port)
try:
self.connection = httplib.HTTPConnection(self.url.hostname, self.url.port)
self.connection.connect()
except (http... | python | def connect(self):
"""Opens a HTTP connection to the RPC server."""
logger.debug("Opening connection to %s:%s", self.url.hostname, self.url.port)
try:
self.connection = httplib.HTTPConnection(self.url.hostname, self.url.port)
self.connection.connect()
except (http... | [
"def",
"connect",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Opening connection to %s:%s\"",
",",
"self",
".",
"url",
".",
"hostname",
",",
"self",
".",
"url",
".",
"port",
")",
"try",
":",
"self",
".",
"connection",
"=",
"httplib",
".",
"H... | Opens a HTTP connection to the RPC server. | [
"Opens",
"a",
"HTTP",
"connection",
"to",
"the",
"RPC",
"server",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L151-L158 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.close | def close(self):
"""Closes the HTTP connection to the RPC server."""
if self.connection is not None:
logger.debug("Closing connection to %s:%s", self.url.hostname, self.url.port)
try:
self.connection.close()
except httplib.HTTPException:
... | python | def close(self):
"""Closes the HTTP connection to the RPC server."""
if self.connection is not None:
logger.debug("Closing connection to %s:%s", self.url.hostname, self.url.port)
try:
self.connection.close()
except httplib.HTTPException:
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"connection",
"is",
"not",
"None",
":",
"logger",
".",
"debug",
"(",
"\"Closing connection to %s:%s\"",
",",
"self",
".",
"url",
".",
"hostname",
",",
"self",
".",
"url",
".",
"port",
")",
"try"... | Closes the HTTP connection to the RPC server. | [
"Closes",
"the",
"HTTP",
"connection",
"to",
"the",
"RPC",
"server",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L160-L168 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.connection_sync | def connection_sync(self, connection_id, connProps=None):
"""Synchronizes connection properties with the server.
:param connection_id:
ID of the current connection.
:param connProps:
Dictionary with the properties that should be changed.
:returns:
A... | python | def connection_sync(self, connection_id, connProps=None):
"""Synchronizes connection properties with the server.
:param connection_id:
ID of the current connection.
:param connProps:
Dictionary with the properties that should be changed.
:returns:
A... | [
"def",
"connection_sync",
"(",
"self",
",",
"connection_id",
",",
"connProps",
"=",
"None",
")",
":",
"if",
"connProps",
"is",
"None",
":",
"connProps",
"=",
"{",
"}",
"request",
"=",
"requests_pb2",
".",
"ConnectionSyncRequest",
"(",
")",
"request",
".",
... | Synchronizes connection properties with the server.
:param connection_id:
ID of the current connection.
:param connProps:
Dictionary with the properties that should be changed.
:returns:
A ``common_pb2.ConnectionProperties`` object. | [
"Synchronizes",
"connection",
"properties",
"with",
"the",
"server",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L286-L314 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.open_connection | def open_connection(self, connection_id, info=None):
"""Opens a new connection.
:param connection_id:
ID of the connection to open.
"""
request = requests_pb2.OpenConnectionRequest()
request.connection_id = connection_id
if info is not None:
# Inf... | python | def open_connection(self, connection_id, info=None):
"""Opens a new connection.
:param connection_id:
ID of the connection to open.
"""
request = requests_pb2.OpenConnectionRequest()
request.connection_id = connection_id
if info is not None:
# Inf... | [
"def",
"open_connection",
"(",
"self",
",",
"connection_id",
",",
"info",
"=",
"None",
")",
":",
"request",
"=",
"requests_pb2",
".",
"OpenConnectionRequest",
"(",
")",
"request",
".",
"connection_id",
"=",
"connection_id",
"if",
"info",
"is",
"not",
"None",
... | Opens a new connection.
:param connection_id:
ID of the connection to open. | [
"Opens",
"a",
"new",
"connection",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L316-L331 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.close_connection | def close_connection(self, connection_id):
"""Closes a connection.
:param connection_id:
ID of the connection to close.
"""
request = requests_pb2.CloseConnectionRequest()
request.connection_id = connection_id
self._apply(request) | python | def close_connection(self, connection_id):
"""Closes a connection.
:param connection_id:
ID of the connection to close.
"""
request = requests_pb2.CloseConnectionRequest()
request.connection_id = connection_id
self._apply(request) | [
"def",
"close_connection",
"(",
"self",
",",
"connection_id",
")",
":",
"request",
"=",
"requests_pb2",
".",
"CloseConnectionRequest",
"(",
")",
"request",
".",
"connection_id",
"=",
"connection_id",
"self",
".",
"_apply",
"(",
"request",
")"
] | Closes a connection.
:param connection_id:
ID of the connection to close. | [
"Closes",
"a",
"connection",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L333-L341 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.create_statement | def create_statement(self, connection_id):
"""Creates a new statement.
:param connection_id:
ID of the current connection.
:returns:
New statement ID.
"""
request = requests_pb2.CreateStatementRequest()
request.connection_id = connection_id
... | python | def create_statement(self, connection_id):
"""Creates a new statement.
:param connection_id:
ID of the current connection.
:returns:
New statement ID.
"""
request = requests_pb2.CreateStatementRequest()
request.connection_id = connection_id
... | [
"def",
"create_statement",
"(",
"self",
",",
"connection_id",
")",
":",
"request",
"=",
"requests_pb2",
".",
"CreateStatementRequest",
"(",
")",
"request",
".",
"connection_id",
"=",
"connection_id",
"response_data",
"=",
"self",
".",
"_apply",
"(",
"request",
"... | Creates a new statement.
:param connection_id:
ID of the current connection.
:returns:
New statement ID. | [
"Creates",
"a",
"new",
"statement",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L343-L358 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.close_statement | def close_statement(self, connection_id, statement_id):
"""Closes a statement.
:param connection_id:
ID of the current connection.
:param statement_id:
ID of the statement to close.
"""
request = requests_pb2.CloseStatementRequest()
request.conne... | python | def close_statement(self, connection_id, statement_id):
"""Closes a statement.
:param connection_id:
ID of the current connection.
:param statement_id:
ID of the statement to close.
"""
request = requests_pb2.CloseStatementRequest()
request.conne... | [
"def",
"close_statement",
"(",
"self",
",",
"connection_id",
",",
"statement_id",
")",
":",
"request",
"=",
"requests_pb2",
".",
"CloseStatementRequest",
"(",
")",
"request",
".",
"connection_id",
"=",
"connection_id",
"request",
".",
"statement_id",
"=",
"stateme... | Closes a statement.
:param connection_id:
ID of the current connection.
:param statement_id:
ID of the statement to close. | [
"Closes",
"a",
"statement",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L360-L373 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.prepare_and_execute | def prepare_and_execute(self, connection_id, statement_id, sql, max_rows_total=None, first_frame_max_size=None):
"""Prepares and immediately executes a statement.
:param connection_id:
ID of the current connection.
:param statement_id:
ID of the statement to prepare.
... | python | def prepare_and_execute(self, connection_id, statement_id, sql, max_rows_total=None, first_frame_max_size=None):
"""Prepares and immediately executes a statement.
:param connection_id:
ID of the current connection.
:param statement_id:
ID of the statement to prepare.
... | [
"def",
"prepare_and_execute",
"(",
"self",
",",
"connection_id",
",",
"statement_id",
",",
"sql",
",",
"max_rows_total",
"=",
"None",
",",
"first_frame_max_size",
"=",
"None",
")",
":",
"request",
"=",
"requests_pb2",
".",
"PrepareAndExecuteRequest",
"(",
")",
"... | Prepares and immediately executes a statement.
:param connection_id:
ID of the current connection.
:param statement_id:
ID of the statement to prepare.
:param sql:
SQL query.
:param max_rows_total:
The maximum number of rows that will b... | [
"Prepares",
"and",
"immediately",
"executes",
"a",
"statement",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L375-L408 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.prepare | def prepare(self, connection_id, sql, max_rows_total=None):
"""Prepares a statement.
:param connection_id:
ID of the current connection.
:param sql:
SQL query.
:param max_rows_total:
The maximum number of rows that will be allowed for this query.
... | python | def prepare(self, connection_id, sql, max_rows_total=None):
"""Prepares a statement.
:param connection_id:
ID of the current connection.
:param sql:
SQL query.
:param max_rows_total:
The maximum number of rows that will be allowed for this query.
... | [
"def",
"prepare",
"(",
"self",
",",
"connection_id",
",",
"sql",
",",
"max_rows_total",
"=",
"None",
")",
":",
"request",
"=",
"requests_pb2",
".",
"PrepareRequest",
"(",
")",
"request",
".",
"connection_id",
"=",
"connection_id",
"request",
".",
"sql",
"=",... | Prepares a statement.
:param connection_id:
ID of the current connection.
:param sql:
SQL query.
:param max_rows_total:
The maximum number of rows that will be allowed for this query.
:returns:
Signature of the prepared statement. | [
"Prepares",
"a",
"statement",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L410-L434 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.execute | def execute(self, connection_id, statement_id, signature, parameter_values=None, first_frame_max_size=None):
"""Returns a frame of rows.
The frame describes whether there may be another frame. If there is not
another frame, the current iteration is done when we have finished the
rows in... | python | def execute(self, connection_id, statement_id, signature, parameter_values=None, first_frame_max_size=None):
"""Returns a frame of rows.
The frame describes whether there may be another frame. If there is not
another frame, the current iteration is done when we have finished the
rows in... | [
"def",
"execute",
"(",
"self",
",",
"connection_id",
",",
"statement_id",
",",
"signature",
",",
"parameter_values",
"=",
"None",
",",
"first_frame_max_size",
"=",
"None",
")",
":",
"request",
"=",
"requests_pb2",
".",
"ExecuteRequest",
"(",
")",
"request",
".... | Returns a frame of rows.
The frame describes whether there may be another frame. If there is not
another frame, the current iteration is done when we have finished the
rows in the this frame.
:param connection_id:
ID of the current connection.
:param statement_id:
... | [
"Returns",
"a",
"frame",
"of",
"rows",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L436-L475 | train |
lalinsky/python-phoenixdb | phoenixdb/avatica/client.py | AvaticaClient.fetch | def fetch(self, connection_id, statement_id, offset=0, frame_max_size=None):
"""Returns a frame of rows.
The frame describes whether there may be another frame. If there is not
another frame, the current iteration is done when we have finished the
rows in the this frame.
:param... | python | def fetch(self, connection_id, statement_id, offset=0, frame_max_size=None):
"""Returns a frame of rows.
The frame describes whether there may be another frame. If there is not
another frame, the current iteration is done when we have finished the
rows in the this frame.
:param... | [
"def",
"fetch",
"(",
"self",
",",
"connection_id",
",",
"statement_id",
",",
"offset",
"=",
"0",
",",
"frame_max_size",
"=",
"None",
")",
":",
"request",
"=",
"requests_pb2",
".",
"FetchRequest",
"(",
")",
"request",
".",
"connection_id",
"=",
"connection_id... | Returns a frame of rows.
The frame describes whether there may be another frame. If there is not
another frame, the current iteration is done when we have finished the
rows in the this frame.
:param connection_id:
ID of the current connection.
:param statement_id:
... | [
"Returns",
"a",
"frame",
"of",
"rows",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/avatica/client.py#L477-L509 | train |
lalinsky/python-phoenixdb | phoenixdb/cursor.py | Cursor.close | def close(self):
"""Closes the cursor.
No further operations are allowed once the cursor is closed.
If the cursor is used in a ``with`` statement, this method will
be automatically called at the end of the ``with`` block.
"""
if self._closed:
raise Programmin... | python | def close(self):
"""Closes the cursor.
No further operations are allowed once the cursor is closed.
If the cursor is used in a ``with`` statement, this method will
be automatically called at the end of the ``with`` block.
"""
if self._closed:
raise Programmin... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closed",
":",
"raise",
"ProgrammingError",
"(",
"'the cursor is already closed'",
")",
"if",
"self",
".",
"_id",
"is",
"not",
"None",
":",
"self",
".",
"_connection",
".",
"_client",
".",
"close_s... | Closes the cursor.
No further operations are allowed once the cursor is closed.
If the cursor is used in a ``with`` statement, this method will
be automatically called at the end of the ``with`` block. | [
"Closes",
"the",
"cursor",
".",
"No",
"further",
"operations",
"are",
"allowed",
"once",
"the",
"cursor",
"is",
"closed",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/cursor.py#L86-L102 | train |
lalinsky/python-phoenixdb | phoenixdb/cursor.py | Cursor._transform_row | def _transform_row(self, row):
"""Transforms a Row into Python values.
:param row:
A ``common_pb2.Row`` object.
:returns:
A list of values casted into the correct Python types.
:raises:
NotImplementedError
"""
tmp_row = []
f... | python | def _transform_row(self, row):
"""Transforms a Row into Python values.
:param row:
A ``common_pb2.Row`` object.
:returns:
A list of values casted into the correct Python types.
:raises:
NotImplementedError
"""
tmp_row = []
f... | [
"def",
"_transform_row",
"(",
"self",
",",
"row",
")",
":",
"tmp_row",
"=",
"[",
"]",
"for",
"i",
",",
"column",
"in",
"enumerate",
"(",
"row",
".",
"value",
")",
":",
"if",
"column",
".",
"has_array_value",
":",
"raise",
"NotImplementedError",
"(",
"'... | Transforms a Row into Python values.
:param row:
A ``common_pb2.Row`` object.
:returns:
A list of values casted into the correct Python types.
:raises:
NotImplementedError | [
"Transforms",
"a",
"Row",
"into",
"Python",
"values",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/cursor.py#L233-L263 | train |
lalinsky/python-phoenixdb | phoenixdb/cursor.py | Cursor.rownumber | def rownumber(self):
"""Read-only attribute providing the current 0-based index of the
cursor in the result set or ``None`` if the index cannot be
determined.
The index can be seen as index of the cursor in a sequence
(the result set). The next fetch operation will fetch the
... | python | def rownumber(self):
"""Read-only attribute providing the current 0-based index of the
cursor in the result set or ``None`` if the index cannot be
determined.
The index can be seen as index of the cursor in a sequence
(the result set). The next fetch operation will fetch the
... | [
"def",
"rownumber",
"(",
"self",
")",
":",
"if",
"self",
".",
"_frame",
"is",
"not",
"None",
"and",
"self",
".",
"_pos",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_frame",
".",
"offset",
"+",
"self",
".",
"_pos",
"return",
"self",
".",
"_po... | Read-only attribute providing the current 0-based index of the
cursor in the result set or ``None`` if the index cannot be
determined.
The index can be seen as index of the cursor in a sequence
(the result set). The next fetch operation will fetch the
row indexed by :attr:`rownu... | [
"Read",
"-",
"only",
"attribute",
"providing",
"the",
"current",
"0",
"-",
"based",
"index",
"of",
"the",
"cursor",
"in",
"the",
"result",
"set",
"or",
"None",
"if",
"the",
"index",
"cannot",
"be",
"determined",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/cursor.py#L324-L335 | train |
lalinsky/python-phoenixdb | phoenixdb/types.py | Timestamp | def Timestamp(year, month, day, hour, minute, second):
"""Constructs an object holding a datetime/timestamp value."""
return datetime.datetime(year, month, day, hour, minute, second) | python | def Timestamp(year, month, day, hour, minute, second):
"""Constructs an object holding a datetime/timestamp value."""
return datetime.datetime(year, month, day, hour, minute, second) | [
"def",
"Timestamp",
"(",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
")",
":",
"return",
"datetime",
".",
"datetime",
"(",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
")"
] | Constructs an object holding a datetime/timestamp value. | [
"Constructs",
"an",
"object",
"holding",
"a",
"datetime",
"/",
"timestamp",
"value",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/types.py#L38-L40 | train |
lalinsky/python-phoenixdb | phoenixdb/connection.py | Connection.open | def open(self):
"""Opens the connection."""
self._id = str(uuid.uuid4())
self._client.open_connection(self._id, info=self._connection_args) | python | def open(self):
"""Opens the connection."""
self._id = str(uuid.uuid4())
self._client.open_connection(self._id, info=self._connection_args) | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"_id",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"self",
".",
"_client",
".",
"open_connection",
"(",
"self",
".",
"_id",
",",
"info",
"=",
"self",
".",
"_connection_args",
")"
] | Opens the connection. | [
"Opens",
"the",
"connection",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/connection.py#L70-L73 | train |
lalinsky/python-phoenixdb | phoenixdb/connection.py | Connection.close | def close(self):
"""Closes the connection.
No further operations are allowed, either on the connection or any
of its cursors, once the connection is closed.
If the connection is used in a ``with`` statement, this method will
be automatically called at the end of the ``with`` blo... | python | def close(self):
"""Closes the connection.
No further operations are allowed, either on the connection or any
of its cursors, once the connection is closed.
If the connection is used in a ``with`` statement, this method will
be automatically called at the end of the ``with`` blo... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closed",
":",
"raise",
"ProgrammingError",
"(",
"'the connection is already closed'",
")",
"for",
"cursor_ref",
"in",
"self",
".",
"_cursors",
":",
"cursor",
"=",
"cursor_ref",
"(",
")",
"if",
"curs... | Closes the connection.
No further operations are allowed, either on the connection or any
of its cursors, once the connection is closed.
If the connection is used in a ``with`` statement, this method will
be automatically called at the end of the ``with`` block. | [
"Closes",
"the",
"connection",
".",
"No",
"further",
"operations",
"are",
"allowed",
"either",
"on",
"the",
"connection",
"or",
"any",
"of",
"its",
"cursors",
"once",
"the",
"connection",
"is",
"closed",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/connection.py#L75-L91 | train |
lalinsky/python-phoenixdb | phoenixdb/connection.py | Connection.cursor | def cursor(self, cursor_factory=None):
"""Creates a new cursor.
:param cursor_factory:
This argument can be used to create non-standard cursors.
The class returned must be a subclass of
:class:`~phoenixdb.cursor.Cursor` (for example :class:`~phoenixdb.cursor.DictCurs... | python | def cursor(self, cursor_factory=None):
"""Creates a new cursor.
:param cursor_factory:
This argument can be used to create non-standard cursors.
The class returned must be a subclass of
:class:`~phoenixdb.cursor.Cursor` (for example :class:`~phoenixdb.cursor.DictCurs... | [
"def",
"cursor",
"(",
"self",
",",
"cursor_factory",
"=",
"None",
")",
":",
"if",
"self",
".",
"_closed",
":",
"raise",
"ProgrammingError",
"(",
"'the connection is already closed'",
")",
"cursor",
"=",
"(",
"cursor_factory",
"or",
"self",
".",
"cursor_factory",... | Creates a new cursor.
:param cursor_factory:
This argument can be used to create non-standard cursors.
The class returned must be a subclass of
:class:`~phoenixdb.cursor.Cursor` (for example :class:`~phoenixdb.cursor.DictCursor`).
A default factory for the connec... | [
"Creates",
"a",
"new",
"cursor",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/connection.py#L109-L126 | train |
lalinsky/python-phoenixdb | phoenixdb/connection.py | Connection.set_session | def set_session(self, autocommit=None, readonly=None):
"""Sets one or more parameters in the current connection.
:param autocommit:
Switch the connection to autocommit mode. With the current
version, you need to always enable this, because
:meth:`commit` is not imple... | python | def set_session(self, autocommit=None, readonly=None):
"""Sets one or more parameters in the current connection.
:param autocommit:
Switch the connection to autocommit mode. With the current
version, you need to always enable this, because
:meth:`commit` is not imple... | [
"def",
"set_session",
"(",
"self",
",",
"autocommit",
"=",
"None",
",",
"readonly",
"=",
"None",
")",
":",
"props",
"=",
"{",
"}",
"if",
"autocommit",
"is",
"not",
"None",
":",
"props",
"[",
"'autoCommit'",
"]",
"=",
"bool",
"(",
"autocommit",
")",
"... | Sets one or more parameters in the current connection.
:param autocommit:
Switch the connection to autocommit mode. With the current
version, you need to always enable this, because
:meth:`commit` is not implemented.
:param readonly:
Switch the connectio... | [
"Sets",
"one",
"or",
"more",
"parameters",
"in",
"the",
"current",
"connection",
"."
] | 1bb34488dd530ca65f91b29ef16aa7b71f26b806 | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/connection.py#L128-L147 | train |
wdm0006/sklearn-extensions | sklearn_extensions/kernel_regression/kr.py | KernelRegression.fit | def fit(self, X, y):
"""Fit the model
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The training input samples.
y : array-like, shape = [n_samples]
The target values
Returns
-------
self : object
... | python | def fit(self, X, y):
"""Fit the model
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The training input samples.
y : array-like, shape = [n_samples]
The target values
Returns
-------
self : object
... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
")",
":",
"self",
".",
"X",
"=",
"X",
"self",
".",
"y",
"=",
"y",
"if",
"hasattr",
"(",
"self",
".",
"gamma",
",",
"\"__iter__\"",
")",
":",
"self",
".",
"gamma",
"=",
"self",
".",
"_optimize_gamma... | Fit the model
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The training input samples.
y : array-like, shape = [n_samples]
The target values
Returns
-------
self : object
Returns self. | [
"Fit",
"the",
"model"
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/kernel_regression/kr.py#L46-L68 | train |
wdm0006/sklearn-extensions | sklearn_extensions/kernel_regression/kr.py | KernelRegression.predict | def predict(self, X):
"""Predict target values for X.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
y : array of shape = [n_samples]
The predicted target value.
"""
... | python | def predict(self, X):
"""Predict target values for X.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
y : array of shape = [n_samples]
The predicted target value.
"""
... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"K",
"=",
"pairwise_kernels",
"(",
"self",
".",
"X",
",",
"X",
",",
"metric",
"=",
"self",
".",
"kernel",
",",
"gamma",
"=",
"self",
".",
"gamma",
")",
"return",
"(",
"K",
"*",
"self",
".",
"y"... | Predict target values for X.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
y : array of shape = [n_samples]
The predicted target value. | [
"Predict",
"target",
"values",
"for",
"X",
"."
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/kernel_regression/kr.py#L70-L84 | train |
wdm0006/sklearn-extensions | sklearn_extensions/extreme_learning_machines/random_layer.py | BaseRandomLayer._compute_hidden_activations | def _compute_hidden_activations(self, X):
"""Compute hidden activations given X"""
self._compute_input_activations(X)
acts = self.input_activations_
if (callable(self.activation_func)):
args_dict = self.activation_args if (self.activation_args) else {}
X_new = ... | python | def _compute_hidden_activations(self, X):
"""Compute hidden activations given X"""
self._compute_input_activations(X)
acts = self.input_activations_
if (callable(self.activation_func)):
args_dict = self.activation_args if (self.activation_args) else {}
X_new = ... | [
"def",
"_compute_hidden_activations",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"_compute_input_activations",
"(",
"X",
")",
"acts",
"=",
"self",
".",
"input_activations_",
"if",
"(",
"callable",
"(",
"self",
".",
"activation_func",
")",
")",
":",
"args_... | Compute hidden activations given X | [
"Compute",
"hidden",
"activations",
"given",
"X"
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/extreme_learning_machines/random_layer.py#L72-L88 | train |
wdm0006/sklearn-extensions | sklearn_extensions/extreme_learning_machines/random_layer.py | BaseRandomLayer.transform | def transform(self, X, y=None):
"""Generate the random hidden layer's activations given X as input.
Parameters
----------
X : {array-like, sparse matrix}, shape [n_samples, n_features]
Data to transform
y : is not used: placeholder to allow for usage in a Pipeline.
... | python | def transform(self, X, y=None):
"""Generate the random hidden layer's activations given X as input.
Parameters
----------
X : {array-like, sparse matrix}, shape [n_samples, n_features]
Data to transform
y : is not used: placeholder to allow for usage in a Pipeline.
... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"if",
"(",
"self",
".",
"components_",
"is",
"None",
")",
":",
"raise",
"ValueError",
"(",
"'No components initialized'",
")",
"return",
"self",
".",
"_compute_hidden_activations",
... | Generate the random hidden layer's activations given X as input.
Parameters
----------
X : {array-like, sparse matrix}, shape [n_samples, n_features]
Data to transform
y : is not used: placeholder to allow for usage in a Pipeline.
Returns
-------
X_... | [
"Generate",
"the",
"random",
"hidden",
"layer",
"s",
"activations",
"given",
"X",
"as",
"input",
"."
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/extreme_learning_machines/random_layer.py#L114-L132 | train |
wdm0006/sklearn-extensions | sklearn_extensions/extreme_learning_machines/random_layer.py | RandomLayer._compute_radii | def _compute_radii(self):
"""Generate RBF radii"""
# use supplied radii if present
radii = self._get_user_components('radii')
# compute radii
if (radii is None):
centers = self.components_['centers']
n_centers = centers.shape[0]
max_dist = n... | python | def _compute_radii(self):
"""Generate RBF radii"""
# use supplied radii if present
radii = self._get_user_components('radii')
# compute radii
if (radii is None):
centers = self.components_['centers']
n_centers = centers.shape[0]
max_dist = n... | [
"def",
"_compute_radii",
"(",
"self",
")",
":",
"# use supplied radii if present",
"radii",
"=",
"self",
".",
"_get_user_components",
"(",
"'radii'",
")",
"# compute radii",
"if",
"(",
"radii",
"is",
"None",
")",
":",
"centers",
"=",
"self",
".",
"components_",
... | Generate RBF radii | [
"Generate",
"RBF",
"radii"
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/extreme_learning_machines/random_layer.py#L280-L294 | train |
wdm0006/sklearn-extensions | sklearn_extensions/extreme_learning_machines/random_layer.py | RandomLayer._compute_centers | def _compute_centers(self, X, sparse, rs):
"""Generate RBF centers"""
# use supplied centers if present
centers = self._get_user_components('centers')
# use points taken uniformly from the bounding
# hyperrectangle
if (centers is None):
n_features = X.shape[... | python | def _compute_centers(self, X, sparse, rs):
"""Generate RBF centers"""
# use supplied centers if present
centers = self._get_user_components('centers')
# use points taken uniformly from the bounding
# hyperrectangle
if (centers is None):
n_features = X.shape[... | [
"def",
"_compute_centers",
"(",
"self",
",",
"X",
",",
"sparse",
",",
"rs",
")",
":",
"# use supplied centers if present",
"centers",
"=",
"self",
".",
"_get_user_components",
"(",
"'centers'",
")",
"# use points taken uniformly from the bounding",
"# hyperrectangle",
"... | Generate RBF centers | [
"Generate",
"RBF",
"centers"
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/extreme_learning_machines/random_layer.py#L296-L326 | train |
wdm0006/sklearn-extensions | sklearn_extensions/extreme_learning_machines/random_layer.py | RandomLayer._compute_biases | def _compute_biases(self, rs):
"""Generate MLP biases"""
# use supplied biases if present
biases = self._get_user_components('biases')
if (biases is None):
b_size = self.n_hidden
biases = rs.normal(size=b_size)
self.components_['biases'] = biases | python | def _compute_biases(self, rs):
"""Generate MLP biases"""
# use supplied biases if present
biases = self._get_user_components('biases')
if (biases is None):
b_size = self.n_hidden
biases = rs.normal(size=b_size)
self.components_['biases'] = biases | [
"def",
"_compute_biases",
"(",
"self",
",",
"rs",
")",
":",
"# use supplied biases if present",
"biases",
"=",
"self",
".",
"_get_user_components",
"(",
"'biases'",
")",
"if",
"(",
"biases",
"is",
"None",
")",
":",
"b_size",
"=",
"self",
".",
"n_hidden",
"bi... | Generate MLP biases | [
"Generate",
"MLP",
"biases"
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/extreme_learning_machines/random_layer.py#L328-L337 | train |
wdm0006/sklearn-extensions | sklearn_extensions/extreme_learning_machines/random_layer.py | RandomLayer._compute_weights | def _compute_weights(self, X, rs):
"""Generate MLP weights"""
# use supplied weights if present
weights = self._get_user_components('weights')
if (weights is None):
n_features = X.shape[1]
hw_size = (n_features, self.n_hidden)
weights = rs.normal(size... | python | def _compute_weights(self, X, rs):
"""Generate MLP weights"""
# use supplied weights if present
weights = self._get_user_components('weights')
if (weights is None):
n_features = X.shape[1]
hw_size = (n_features, self.n_hidden)
weights = rs.normal(size... | [
"def",
"_compute_weights",
"(",
"self",
",",
"X",
",",
"rs",
")",
":",
"# use supplied weights if present",
"weights",
"=",
"self",
".",
"_get_user_components",
"(",
"'weights'",
")",
"if",
"(",
"weights",
"is",
"None",
")",
":",
"n_features",
"=",
"X",
".",... | Generate MLP weights | [
"Generate",
"MLP",
"weights"
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/extreme_learning_machines/random_layer.py#L339-L349 | train |
wdm0006/sklearn-extensions | sklearn_extensions/extreme_learning_machines/random_layer.py | RandomLayer._generate_components | def _generate_components(self, X):
"""Generate components of hidden layer given X"""
rs = check_random_state(self.random_state)
if (self._use_mlp_input):
self._compute_biases(rs)
self._compute_weights(X, rs)
if (self._use_rbf_input):
self._compute_ce... | python | def _generate_components(self, X):
"""Generate components of hidden layer given X"""
rs = check_random_state(self.random_state)
if (self._use_mlp_input):
self._compute_biases(rs)
self._compute_weights(X, rs)
if (self._use_rbf_input):
self._compute_ce... | [
"def",
"_generate_components",
"(",
"self",
",",
"X",
")",
":",
"rs",
"=",
"check_random_state",
"(",
"self",
".",
"random_state",
")",
"if",
"(",
"self",
".",
"_use_mlp_input",
")",
":",
"self",
".",
"_compute_biases",
"(",
"rs",
")",
"self",
".",
"_com... | Generate components of hidden layer given X | [
"Generate",
"components",
"of",
"hidden",
"layer",
"given",
"X"
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/extreme_learning_machines/random_layer.py#L351-L361 | train |
wdm0006/sklearn-extensions | sklearn_extensions/extreme_learning_machines/random_layer.py | RandomLayer._compute_input_activations | def _compute_input_activations(self, X):
"""Compute input activations given X"""
n_samples = X.shape[0]
mlp_acts = np.zeros((n_samples, self.n_hidden))
if (self._use_mlp_input):
b = self.components_['biases']
w = self.components_['weights']
mlp_acts ... | python | def _compute_input_activations(self, X):
"""Compute input activations given X"""
n_samples = X.shape[0]
mlp_acts = np.zeros((n_samples, self.n_hidden))
if (self._use_mlp_input):
b = self.components_['biases']
w = self.components_['weights']
mlp_acts ... | [
"def",
"_compute_input_activations",
"(",
"self",
",",
"X",
")",
":",
"n_samples",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
"mlp_acts",
"=",
"np",
".",
"zeros",
"(",
"(",
"n_samples",
",",
"self",
".",
"n_hidden",
")",
")",
"if",
"(",
"self",
".",
"_... | Compute input activations given X | [
"Compute",
"input",
"activations",
"given",
"X"
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/extreme_learning_machines/random_layer.py#L363-L381 | train |
wdm0006/sklearn-extensions | sklearn_extensions/extreme_learning_machines/random_layer.py | GRBFRandomLayer._compute_centers | def _compute_centers(self, X, sparse, rs):
"""Generate centers, then compute tau, dF and dN vals"""
super(GRBFRandomLayer, self)._compute_centers(X, sparse, rs)
centers = self.components_['centers']
sorted_distances = np.sort(squareform(pdist(centers)))
self.dF_vals = sorted_di... | python | def _compute_centers(self, X, sparse, rs):
"""Generate centers, then compute tau, dF and dN vals"""
super(GRBFRandomLayer, self)._compute_centers(X, sparse, rs)
centers = self.components_['centers']
sorted_distances = np.sort(squareform(pdist(centers)))
self.dF_vals = sorted_di... | [
"def",
"_compute_centers",
"(",
"self",
",",
"X",
",",
"sparse",
",",
"rs",
")",
":",
"super",
"(",
"GRBFRandomLayer",
",",
"self",
")",
".",
"_compute_centers",
"(",
"X",
",",
"sparse",
",",
"rs",
")",
"centers",
"=",
"self",
".",
"components_",
"[",
... | Generate centers, then compute tau, dF and dN vals | [
"Generate",
"centers",
"then",
"compute",
"tau",
"dF",
"and",
"dN",
"vals"
] | 329f3efdb8c3c3a367b264f7c76c76411a784530 | https://github.com/wdm0006/sklearn-extensions/blob/329f3efdb8c3c3a367b264f7c76c76411a784530/sklearn_extensions/extreme_learning_machines/random_layer.py#L500-L518 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.