repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd5xx.py | license | def license(self, key, value):
"""Populate the ``license`` key."""
def _get_license(value):
a_values = force_list(value.get('a'))
oa_licenses = [el for el in a_values if el == 'OA' or el == 'Open Access']
other_licenses = [el for el in a_values if el != 'OA' and el != 'Open Access']
... | python | def license(self, key, value):
"""Populate the ``license`` key."""
def _get_license(value):
a_values = force_list(value.get('a'))
oa_licenses = [el for el in a_values if el == 'OA' or el == 'Open Access']
other_licenses = [el for el in a_values if el != 'OA' and el != 'Open Access']
... | [
"def",
"license",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_license",
"(",
"value",
")",
":",
"a_values",
"=",
"force_list",
"(",
"value",
".",
"get",
"(",
"'a'",
")",
")",
"oa_licenses",
"=",
"[",
"el",
"for",
"el",
"in",
"a_va... | Populate the ``license`` key. | [
"Populate",
"the",
"license",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L221-L244 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd5xx.py | license2marc | def license2marc(self, key, value):
"""Populate the ``540`` MARC field."""
return {
'a': value.get('license'),
'b': value.get('imposing'),
'u': value.get('url'),
'3': value.get('material'),
} | python | def license2marc(self, key, value):
"""Populate the ``540`` MARC field."""
return {
'a': value.get('license'),
'b': value.get('imposing'),
'u': value.get('url'),
'3': value.get('material'),
} | [
"def",
"license2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'a'",
":",
"value",
".",
"get",
"(",
"'license'",
")",
",",
"'b'",
":",
"value",
".",
"get",
"(",
"'imposing'",
")",
",",
"'u'",
":",
"value",
".",
"get",
"("... | Populate the ``540`` MARC field. | [
"Populate",
"the",
"540",
"MARC",
"field",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L249-L256 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd5xx.py | copyright | def copyright(self, key, value):
"""Populate the ``copyright`` key."""
MATERIAL_MAP = {
'Article': 'publication',
'Published thesis as a book': 'publication',
}
material = value.get('e') or value.get('3')
return {
'holder': value.get('d'),
'material': MATERIAL_MAP.g... | python | def copyright(self, key, value):
"""Populate the ``copyright`` key."""
MATERIAL_MAP = {
'Article': 'publication',
'Published thesis as a book': 'publication',
}
material = value.get('e') or value.get('3')
return {
'holder': value.get('d'),
'material': MATERIAL_MAP.g... | [
"def",
"copyright",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"MATERIAL_MAP",
"=",
"{",
"'Article'",
":",
"'publication'",
",",
"'Published thesis as a book'",
":",
"'publication'",
",",
"}",
"material",
"=",
"value",
".",
"get",
"(",
"'e'",
")",
"o... | Populate the ``copyright`` key. | [
"Populate",
"the",
"copyright",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L261-L276 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd5xx.py | copyright2marc | def copyright2marc(self, key, value):
"""Populate the ``542`` MARC field."""
E_MAP = {
'publication': 'Article',
}
e_value = value.get('material')
return {
'd': value.get('holder'),
'e': E_MAP.get(e_value),
'f': value.get('statement'),
'g': value.get('year')... | python | def copyright2marc(self, key, value):
"""Populate the ``542`` MARC field."""
E_MAP = {
'publication': 'Article',
}
e_value = value.get('material')
return {
'd': value.get('holder'),
'e': E_MAP.get(e_value),
'f': value.get('statement'),
'g': value.get('year')... | [
"def",
"copyright2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"E_MAP",
"=",
"{",
"'publication'",
":",
"'Article'",
",",
"}",
"e_value",
"=",
"value",
".",
"get",
"(",
"'material'",
")",
"return",
"{",
"'d'",
":",
"value",
".",
"get",
"("... | Populate the ``542`` MARC field. | [
"Populate",
"the",
"542",
"MARC",
"field",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L281-L295 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd5xx.py | _private_notes | def _private_notes(self, key, value):
"""Populate the ``_private_notes`` key.
Also populates the ``_export_to`` key through side effects.
"""
def _is_for_cds(value):
normalized_c_values = [el.upper() for el in force_list(value.get('c'))]
return 'CDS' in normalized_c_values
def _is_... | python | def _private_notes(self, key, value):
"""Populate the ``_private_notes`` key.
Also populates the ``_export_to`` key through side effects.
"""
def _is_for_cds(value):
normalized_c_values = [el.upper() for el in force_list(value.get('c'))]
return 'CDS' in normalized_c_values
def _is_... | [
"def",
"_private_notes",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_for_cds",
"(",
"value",
")",
":",
"normalized_c_values",
"=",
"[",
"el",
".",
"upper",
"(",
")",
"for",
"el",
"in",
"force_list",
"(",
"value",
".",
"get",
"(",
"'c... | Populate the ``_private_notes`` key.
Also populates the ``_export_to`` key through side effects. | [
"Populate",
"the",
"_private_notes",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L299-L336 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd5xx.py | _private_notes2marc | def _private_notes2marc(self, key, value):
"""Populate the ``595`` MARC key.
Also populates the `595_H` MARC key through side effects.
"""
def _is_from_hal(value):
return value.get('source') == 'HAL'
if not _is_from_hal(value):
return {
'9': value.get('source'),
... | python | def _private_notes2marc(self, key, value):
"""Populate the ``595`` MARC key.
Also populates the `595_H` MARC key through side effects.
"""
def _is_from_hal(value):
return value.get('source') == 'HAL'
if not _is_from_hal(value):
return {
'9': value.get('source'),
... | [
"def",
"_private_notes2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_from_hal",
"(",
"value",
")",
":",
"return",
"value",
".",
"get",
"(",
"'source'",
")",
"==",
"'HAL'",
"if",
"not",
"_is_from_hal",
"(",
"value",
")",
":",
"retu... | Populate the ``595`` MARC key.
Also populates the `595_H` MARC key through side effects. | [
"Populate",
"the",
"595",
"MARC",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L341-L355 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd5xx.py | _export_to2marc | def _export_to2marc(self, key, value):
"""Populate the ``595`` MARC field."""
def _is_for_cds(value):
return 'CDS' in value
def _is_for_hal(value):
return 'HAL' in value and value['HAL']
def _is_not_for_hal(value):
return 'HAL' in value and not value['HAL']
result = []
... | python | def _export_to2marc(self, key, value):
"""Populate the ``595`` MARC field."""
def _is_for_cds(value):
return 'CDS' in value
def _is_for_hal(value):
return 'HAL' in value and value['HAL']
def _is_not_for_hal(value):
return 'HAL' in value and not value['HAL']
result = []
... | [
"def",
"_export_to2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_for_cds",
"(",
"value",
")",
":",
"return",
"'CDS'",
"in",
"value",
"def",
"_is_for_hal",
"(",
"value",
")",
":",
"return",
"'HAL'",
"in",
"value",
"and",
"value",
"... | Populate the ``595`` MARC field. | [
"Populate",
"the",
"595",
"MARC",
"field",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L359-L380 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd5xx.py | _desy_bookkeeping | def _desy_bookkeeping(self, key, value):
"""Populate the ``_desy_bookkeeping`` key."""
return {
'date': normalize_date(value.get('d')),
'expert': force_single_element(value.get('a')),
'status': value.get('s'),
} | python | def _desy_bookkeeping(self, key, value):
"""Populate the ``_desy_bookkeeping`` key."""
return {
'date': normalize_date(value.get('d')),
'expert': force_single_element(value.get('a')),
'status': value.get('s'),
} | [
"def",
"_desy_bookkeeping",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'date'",
":",
"normalize_date",
"(",
"value",
".",
"get",
"(",
"'d'",
")",
")",
",",
"'expert'",
":",
"force_single_element",
"(",
"value",
".",
"get",
"(",
"'... | Populate the ``_desy_bookkeeping`` key. | [
"Populate",
"the",
"_desy_bookkeeping",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L385-L391 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd5xx.py | _desy_bookkeeping2marc | def _desy_bookkeeping2marc(self, key, value):
"""Populate the ``595_D`` MARC field.
Also populates the ``035`` MARC field through side effects.
"""
if 'identifier' not in value:
return {
'a': value.get('expert'),
'd': value.get('date'),
's': value.get('status... | python | def _desy_bookkeeping2marc(self, key, value):
"""Populate the ``595_D`` MARC field.
Also populates the ``035`` MARC field through side effects.
"""
if 'identifier' not in value:
return {
'a': value.get('expert'),
'd': value.get('date'),
's': value.get('status... | [
"def",
"_desy_bookkeeping2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"'identifier'",
"not",
"in",
"value",
":",
"return",
"{",
"'a'",
":",
"value",
".",
"get",
"(",
"'expert'",
")",
",",
"'d'",
":",
"value",
".",
"get",
"(",
"'date... | Populate the ``595_D`` MARC field.
Also populates the ``035`` MARC field through side effects. | [
"Populate",
"the",
"595_D",
"MARC",
"field",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L396-L411 |
inspirehep/inspire-dojson | inspire_dojson/experiments/rules.py | _dates | def _dates(self, key, value):
"""Don't populate any key through the return value.
On the other hand, populates the ``date_proposed``, ``date_approved``,
``date_started``, ``date_cancelled``, and the ``date_completed`` keys
through side effects.
"""
if value.get('q'):
self['date_proposed... | python | def _dates(self, key, value):
"""Don't populate any key through the return value.
On the other hand, populates the ``date_proposed``, ``date_approved``,
``date_started``, ``date_cancelled``, and the ``date_completed`` keys
through side effects.
"""
if value.get('q'):
self['date_proposed... | [
"def",
"_dates",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"value",
".",
"get",
"(",
"'q'",
")",
":",
"self",
"[",
"'date_proposed'",
"]",
"=",
"normalize_date",
"(",
"value",
"[",
"'q'",
"]",
")",
"if",
"value",
".",
"get",
"(",
"'r... | Don't populate any key through the return value.
On the other hand, populates the ``date_proposed``, ``date_approved``,
``date_started``, ``date_cancelled``, and the ``date_completed`` keys
through side effects. | [
"Don",
"t",
"populate",
"any",
"key",
"through",
"the",
"return",
"value",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/experiments/rules.py#L42-L60 |
inspirehep/inspire-dojson | inspire_dojson/experiments/rules.py | experiment | def experiment(self, key, values):
"""Populate the ``experiment`` key.
Also populates the ``legacy_name``, the ``accelerator``, and the
``institutions`` keys through side effects.
"""
experiment = self.get('experiment', {})
legacy_name = self.get('legacy_name', '')
accelerator = self.get('a... | python | def experiment(self, key, values):
"""Populate the ``experiment`` key.
Also populates the ``legacy_name``, the ``accelerator``, and the
``institutions`` keys through side effects.
"""
experiment = self.get('experiment', {})
legacy_name = self.get('legacy_name', '')
accelerator = self.get('a... | [
"def",
"experiment",
"(",
"self",
",",
"key",
",",
"values",
")",
":",
"experiment",
"=",
"self",
".",
"get",
"(",
"'experiment'",
",",
"{",
"}",
")",
"legacy_name",
"=",
"self",
".",
"get",
"(",
"'legacy_name'",
",",
"''",
")",
"accelerator",
"=",
"... | Populate the ``experiment`` key.
Also populates the ``legacy_name``, the ``accelerator``, and the
``institutions`` keys through side effects. | [
"Populate",
"the",
"experiment",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/experiments/rules.py#L64-L100 |
inspirehep/inspire-dojson | inspire_dojson/experiments/rules.py | core | def core(self, key, value):
"""Populate the ``core`` key.
Also populates the ``deleted`` and ``project_type`` keys through side
effects.
"""
core = self.get('core')
deleted = self.get('deleted')
project_type = self.get('project_type', [])
if not core:
normalized_a_values = [el.... | python | def core(self, key, value):
"""Populate the ``core`` key.
Also populates the ``deleted`` and ``project_type`` keys through side
effects.
"""
core = self.get('core')
deleted = self.get('deleted')
project_type = self.get('project_type', [])
if not core:
normalized_a_values = [el.... | [
"def",
"core",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"core",
"=",
"self",
".",
"get",
"(",
"'core'",
")",
"deleted",
"=",
"self",
".",
"get",
"(",
"'deleted'",
")",
"project_type",
"=",
"self",
".",
"get",
"(",
"'project_type'",
",",
"["... | Populate the ``core`` key.
Also populates the ``deleted`` and ``project_type`` keys through side
effects. | [
"Populate",
"the",
"core",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/experiments/rules.py#L170-L197 |
inspirehep/inspire-dojson | inspire_dojson/common/rules.py | control_number | def control_number(endpoint):
"""Populate the ``control_number`` key.
Also populates the ``self`` key through side effects.
"""
def _control_number(self, key, value):
self['self'] = get_record_ref(int(value), endpoint)
return int(value)
return _control_number | python | def control_number(endpoint):
"""Populate the ``control_number`` key.
Also populates the ``self`` key through side effects.
"""
def _control_number(self, key, value):
self['self'] = get_record_ref(int(value), endpoint)
return int(value)
return _control_number | [
"def",
"control_number",
"(",
"endpoint",
")",
":",
"def",
"_control_number",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
"[",
"'self'",
"]",
"=",
"get_record_ref",
"(",
"int",
"(",
"value",
")",
",",
"endpoint",
")",
"return",
"int",
"(",... | Populate the ``control_number`` key.
Also populates the ``self`` key through side effects. | [
"Populate",
"the",
"control_number",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/common/rules.py#L586-L595 |
inspirehep/inspire-dojson | inspire_dojson/common/rules.py | acquisition_source | def acquisition_source(self, key, value):
"""Populate the ``acquisition_source`` key."""
def _get_datetime(value):
d_value = force_single_element(value.get('d', ''))
if d_value:
try:
date = PartialDate.loads(d_value)
except ValueError:
retu... | python | def acquisition_source(self, key, value):
"""Populate the ``acquisition_source`` key."""
def _get_datetime(value):
d_value = force_single_element(value.get('d', ''))
if d_value:
try:
date = PartialDate.loads(d_value)
except ValueError:
retu... | [
"def",
"acquisition_source",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_datetime",
"(",
"value",
")",
":",
"d_value",
"=",
"force_single_element",
"(",
"value",
".",
"get",
"(",
"'d'",
",",
"''",
")",
")",
"if",
"d_value",
":",
"try"... | Populate the ``acquisition_source`` key. | [
"Populate",
"the",
"acquisition_source",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/common/rules.py#L634-L682 |
inspirehep/inspire-dojson | inspire_dojson/common/rules.py | public_notes_500 | def public_notes_500(self, key, value):
"""Populate the ``public_notes`` key."""
return [
{
'source': value.get('9'),
'value': public_note,
} for public_note in force_list(value.get('a'))
] | python | def public_notes_500(self, key, value):
"""Populate the ``public_notes`` key."""
return [
{
'source': value.get('9'),
'value': public_note,
} for public_note in force_list(value.get('a'))
] | [
"def",
"public_notes_500",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"[",
"{",
"'source'",
":",
"value",
".",
"get",
"(",
"'9'",
")",
",",
"'value'",
":",
"public_note",
",",
"}",
"for",
"public_note",
"in",
"force_list",
"(",
"value",... | Populate the ``public_notes`` key. | [
"Populate",
"the",
"public_notes",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/common/rules.py#L719-L726 |
inspirehep/inspire-dojson | inspire_dojson/common/rules.py | _private_notes_595 | def _private_notes_595(self, key, value):
"""Populate the ``_private_notes`` key."""
return [
{
'source': value.get('9'),
'value': _private_note,
} for _private_note in force_list(value.get('a'))
] | python | def _private_notes_595(self, key, value):
"""Populate the ``_private_notes`` key."""
return [
{
'source': value.get('9'),
'value': _private_note,
} for _private_note in force_list(value.get('a'))
] | [
"def",
"_private_notes_595",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"[",
"{",
"'source'",
":",
"value",
".",
"get",
"(",
"'9'",
")",
",",
"'value'",
":",
"_private_note",
",",
"}",
"for",
"_private_note",
"in",
"force_list",
"(",
"v... | Populate the ``_private_notes`` key. | [
"Populate",
"the",
"_private_notes",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/common/rules.py#L747-L754 |
inspirehep/inspire-dojson | inspire_dojson/common/rules.py | external_system_identifiers | def external_system_identifiers(endpoint):
"""Populate the ``external_system_identifiers`` key.
Also populates the ``new_record`` key through side effects.
"""
@utils.flatten
@utils.for_each_value
def _external_system_identifiers(self, key, value):
new_recid = maybe_int(value.get('d'))
... | python | def external_system_identifiers(endpoint):
"""Populate the ``external_system_identifiers`` key.
Also populates the ``new_record`` key through side effects.
"""
@utils.flatten
@utils.for_each_value
def _external_system_identifiers(self, key, value):
new_recid = maybe_int(value.get('d'))
... | [
"def",
"external_system_identifiers",
"(",
"endpoint",
")",
":",
"@",
"utils",
".",
"flatten",
"@",
"utils",
".",
"for_each_value",
"def",
"_external_system_identifiers",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"new_recid",
"=",
"maybe_int",
"(",
"val... | Populate the ``external_system_identifiers`` key.
Also populates the ``new_record`` key through side effects. | [
"Populate",
"the",
"external_system_identifiers",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/common/rules.py#L901-L920 |
inspirehep/inspire-dojson | inspire_dojson/common/rules.py | deleted_records | def deleted_records(endpoint):
"""Populate the ``deleted_records`` key."""
@utils.for_each_value
def _deleted_records(self, key, value):
deleted_recid = maybe_int(value.get('a'))
if deleted_recid:
return get_record_ref(deleted_recid, endpoint)
return _deleted_records | python | def deleted_records(endpoint):
"""Populate the ``deleted_records`` key."""
@utils.for_each_value
def _deleted_records(self, key, value):
deleted_recid = maybe_int(value.get('a'))
if deleted_recid:
return get_record_ref(deleted_recid, endpoint)
return _deleted_records | [
"def",
"deleted_records",
"(",
"endpoint",
")",
":",
"@",
"utils",
".",
"for_each_value",
"def",
"_deleted_records",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"deleted_recid",
"=",
"maybe_int",
"(",
"value",
".",
"get",
"(",
"'a'",
")",
")",
"if",... | Populate the ``deleted_records`` key. | [
"Populate",
"the",
"deleted_records",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/common/rules.py#L944-L952 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd6xx.py | accelerator_experiments | def accelerator_experiments(self, key, value):
"""Populate the ``accelerator_experiments`` key."""
result = []
a_value = force_single_element(value.get('a'))
e_values = [el for el in force_list(value.get('e')) if el != '-']
zero_values = force_list(value.get('0'))
if a_value and not e_values:
... | python | def accelerator_experiments(self, key, value):
"""Populate the ``accelerator_experiments`` key."""
result = []
a_value = force_single_element(value.get('a'))
e_values = [el for el in force_list(value.get('e')) if el != '-']
zero_values = force_list(value.get('0'))
if a_value and not e_values:
... | [
"def",
"accelerator_experiments",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"result",
"=",
"[",
"]",
"a_value",
"=",
"force_single_element",
"(",
"value",
".",
"get",
"(",
"'a'",
")",
")",
"e_values",
"=",
"[",
"el",
"for",
"el",
"in",
"force_li... | Populate the ``accelerator_experiments`` key. | [
"Populate",
"the",
"accelerator_experiments",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd6xx.py#L53-L76 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd6xx.py | keywords | def keywords(self, key, values):
"""Populate the ``keywords`` key.
Also populates the ``energy_ranges`` key through side effects.
"""
keywords = self.get('keywords', [])
energy_ranges = self.get('energy_ranges', [])
for value in force_list(values):
if value.get('a'):
schema... | python | def keywords(self, key, values):
"""Populate the ``keywords`` key.
Also populates the ``energy_ranges`` key through side effects.
"""
keywords = self.get('keywords', [])
energy_ranges = self.get('energy_ranges', [])
for value in force_list(values):
if value.get('a'):
schema... | [
"def",
"keywords",
"(",
"self",
",",
"key",
",",
"values",
")",
":",
"keywords",
"=",
"self",
".",
"get",
"(",
"'keywords'",
",",
"[",
"]",
")",
"energy_ranges",
"=",
"self",
".",
"get",
"(",
"'energy_ranges'",
",",
"[",
"]",
")",
"for",
"value",
"... | Populate the ``keywords`` key.
Also populates the ``energy_ranges`` key through side effects. | [
"Populate",
"the",
"keywords",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd6xx.py#L90-L117 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd6xx.py | keywords2marc | def keywords2marc(self, key, values):
"""Populate the ``695`` MARC field.
Also populates the ``084`` and ``6531`` MARC fields through side effects.
"""
result_695 = self.get('695', [])
result_084 = self.get('084', [])
result_6531 = self.get('6531', [])
for value in values:
schema =... | python | def keywords2marc(self, key, values):
"""Populate the ``695`` MARC field.
Also populates the ``084`` and ``6531`` MARC fields through side effects.
"""
result_695 = self.get('695', [])
result_084 = self.get('084', [])
result_6531 = self.get('6531', [])
for value in values:
schema =... | [
"def",
"keywords2marc",
"(",
"self",
",",
"key",
",",
"values",
")",
":",
"result_695",
"=",
"self",
".",
"get",
"(",
"'695'",
",",
"[",
"]",
")",
"result_084",
"=",
"self",
".",
"get",
"(",
"'084'",
",",
"[",
"]",
")",
"result_6531",
"=",
"self",
... | Populate the ``695`` MARC field.
Also populates the ``084`` and ``6531`` MARC fields through side effects. | [
"Populate",
"the",
"695",
"MARC",
"field",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd6xx.py#L132-L178 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd7xx.py | collaborations | def collaborations(self, key, value):
"""Populate the ``collaborations`` key."""
result = []
for g_value in force_list(value.get('g')):
collaborations = normalize_collaboration(g_value)
if len(collaborations) == 1:
result.append({
'record': get_record_ref(maybe_i... | python | def collaborations(self, key, value):
"""Populate the ``collaborations`` key."""
result = []
for g_value in force_list(value.get('g')):
collaborations = normalize_collaboration(g_value)
if len(collaborations) == 1:
result.append({
'record': get_record_ref(maybe_i... | [
"def",
"collaborations",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"result",
"=",
"[",
"]",
"for",
"g_value",
"in",
"force_list",
"(",
"value",
".",
"get",
"(",
"'g'",
")",
")",
":",
"collaborations",
"=",
"normalize_collaboration",
"(",
"g_value"... | Populate the ``collaborations`` key. | [
"Populate",
"the",
"collaborations",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd7xx.py#L49-L63 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd7xx.py | publication_info | def publication_info(self, key, value):
"""Populate the ``publication_info`` key."""
def _get_cnum(value):
w_value = force_single_element(value.get('w', ''))
normalized_w_value = w_value.replace('/', '-').upper()
return normalized_w_value
def _get_material(value):
schema = ... | python | def publication_info(self, key, value):
"""Populate the ``publication_info`` key."""
def _get_cnum(value):
w_value = force_single_element(value.get('w', ''))
normalized_w_value = w_value.replace('/', '-').upper()
return normalized_w_value
def _get_material(value):
schema = ... | [
"def",
"publication_info",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_cnum",
"(",
"value",
")",
":",
"w_value",
"=",
"force_single_element",
"(",
"value",
".",
"get",
"(",
"'w'",
",",
"''",
")",
")",
"normalized_w_value",
"=",
"w_value... | Populate the ``publication_info`` key. | [
"Populate",
"the",
"publication_info",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd7xx.py#L75-L132 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd7xx.py | publication_info2marc | def publication_info2marc(self, key, values):
"""Populate the ``773`` MARC field.
Also populates the ``7731`` MARC field through side effects.
"""
result_773 = self.get('773', [])
result_7731 = self.get('7731', [])
for value in force_list(convert_new_publication_info_to_old(values)):
p... | python | def publication_info2marc(self, key, values):
"""Populate the ``773`` MARC field.
Also populates the ``7731`` MARC field through side effects.
"""
result_773 = self.get('773', [])
result_7731 = self.get('7731', [])
for value in force_list(convert_new_publication_info_to_old(values)):
p... | [
"def",
"publication_info2marc",
"(",
"self",
",",
"key",
",",
"values",
")",
":",
"result_773",
"=",
"self",
".",
"get",
"(",
"'773'",
",",
"[",
"]",
")",
"result_7731",
"=",
"self",
".",
"get",
"(",
"'7731'",
",",
"[",
"]",
")",
"for",
"value",
"i... | Populate the ``773`` MARC field.
Also populates the ``7731`` MARC field through side effects. | [
"Populate",
"the",
"773",
"MARC",
"field",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd7xx.py#L136-L174 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd7xx.py | related_records_78002 | def related_records_78002(self, key, value):
"""Populate the ``related_records`` key."""
record = get_record_ref(maybe_int(value.get('w')), 'literature')
if record:
return {
'curated_relation': record is not None,
'record': record,
'relation': 'predecessor',
... | python | def related_records_78002(self, key, value):
"""Populate the ``related_records`` key."""
record = get_record_ref(maybe_int(value.get('w')), 'literature')
if record:
return {
'curated_relation': record is not None,
'record': record,
'relation': 'predecessor',
... | [
"def",
"related_records_78002",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"record",
"=",
"get_record_ref",
"(",
"maybe_int",
"(",
"value",
".",
"get",
"(",
"'w'",
")",
")",
",",
"'literature'",
")",
"if",
"record",
":",
"return",
"{",
"'curated_re... | Populate the ``related_records`` key. | [
"Populate",
"the",
"related_records",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd7xx.py#L179-L187 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd7xx.py | related_records_78502 | def related_records_78502(self, key, value):
"""Populate the ``related_records`` key."""
record = get_record_ref(maybe_int(value.get('w')), 'literature')
if record:
return {
'curated_relation': record is not None,
'record': record,
'relation': 'successor',
... | python | def related_records_78502(self, key, value):
"""Populate the ``related_records`` key."""
record = get_record_ref(maybe_int(value.get('w')), 'literature')
if record:
return {
'curated_relation': record is not None,
'record': record,
'relation': 'successor',
... | [
"def",
"related_records_78502",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"record",
"=",
"get_record_ref",
"(",
"maybe_int",
"(",
"value",
".",
"get",
"(",
"'w'",
")",
")",
",",
"'literature'",
")",
"if",
"record",
":",
"return",
"{",
"'curated_re... | Populate the ``related_records`` key. | [
"Populate",
"the",
"related_records",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd7xx.py#L192-L200 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd7xx.py | related_records_78708 | def related_records_78708(self, key, value):
"""Populate the ``related_records`` key."""
record = get_record_ref(maybe_int(value.get('w')), 'literature')
if record:
return {
'curated_relation': record is not None,
'record': record,
'relation_freetext': value.get('... | python | def related_records_78708(self, key, value):
"""Populate the ``related_records`` key."""
record = get_record_ref(maybe_int(value.get('w')), 'literature')
if record:
return {
'curated_relation': record is not None,
'record': record,
'relation_freetext': value.get('... | [
"def",
"related_records_78708",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"record",
"=",
"get_record_ref",
"(",
"maybe_int",
"(",
"value",
".",
"get",
"(",
"'w'",
")",
")",
",",
"'literature'",
")",
"if",
"record",
":",
"return",
"{",
"'curated_re... | Populate the ``related_records`` key. | [
"Populate",
"the",
"related_records",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd7xx.py#L205-L213 |
inspirehep/inspire-dojson | inspire_dojson/hep/rules/bd7xx.py | related_records2marc | def related_records2marc(self, key, value):
"""Populate the ``78708`` MARC field
Also populates the ``78002``, ``78502`` MARC fields through side effects.
"""
if value.get('relation_freetext'):
return {
'i': value.get('relation_freetext'),
'w': get_recid_from_ref(value.g... | python | def related_records2marc(self, key, value):
"""Populate the ``78708`` MARC field
Also populates the ``78002``, ``78502`` MARC fields through side effects.
"""
if value.get('relation_freetext'):
return {
'i': value.get('relation_freetext'),
'w': get_recid_from_ref(value.g... | [
"def",
"related_records2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"value",
".",
"get",
"(",
"'relation_freetext'",
")",
":",
"return",
"{",
"'i'",
":",
"value",
".",
"get",
"(",
"'relation_freetext'",
")",
",",
"'w'",
":",
"get_recid_... | Populate the ``78708`` MARC field
Also populates the ``78002``, ``78502`` MARC fields through side effects. | [
"Populate",
"the",
"78708",
"MARC",
"field"
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd7xx.py#L218-L239 |
inspirehep/inspire-dojson | inspire_dojson/journals/rules.py | _private_notes | def _private_notes(self, key, value):
"""Populate the ``_private_notes`` key."""
return [
{
'source': value.get('9'),
'value': _private_note,
} for _private_note in force_list(value.get('x'))
] | python | def _private_notes(self, key, value):
"""Populate the ``_private_notes`` key."""
return [
{
'source': value.get('9'),
'value': _private_note,
} for _private_note in force_list(value.get('x'))
] | [
"def",
"_private_notes",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"[",
"{",
"'source'",
":",
"value",
".",
"get",
"(",
"'9'",
")",
",",
"'value'",
":",
"_private_note",
",",
"}",
"for",
"_private_note",
"in",
"force_list",
"(",
"value... | Populate the ``_private_notes`` key. | [
"Populate",
"the",
"_private_notes",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/journals/rules.py#L149-L156 |
inspirehep/inspire-dojson | inspire_dojson/journals/rules.py | proceedings | def proceedings(self, key, value):
"""Populate the ``proceedings`` key.
Also populates the ``refereed`` key through side effects.
"""
proceedings = self.get('proceedings')
refereed = self.get('refereed')
if not proceedings:
normalized_a_values = [el.upper() for el in force_list(value.g... | python | def proceedings(self, key, value):
"""Populate the ``proceedings`` key.
Also populates the ``refereed`` key through side effects.
"""
proceedings = self.get('proceedings')
refereed = self.get('refereed')
if not proceedings:
normalized_a_values = [el.upper() for el in force_list(value.g... | [
"def",
"proceedings",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"proceedings",
"=",
"self",
".",
"get",
"(",
"'proceedings'",
")",
"refereed",
"=",
"self",
".",
"get",
"(",
"'refereed'",
")",
"if",
"not",
"proceedings",
":",
"normalized_a_values",
... | Populate the ``proceedings`` key.
Also populates the ``refereed`` key through side effects. | [
"Populate",
"the",
"proceedings",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/journals/rules.py#L178-L199 |
inspirehep/inspire-dojson | inspire_dojson/journals/rules.py | short_title | def short_title(self, key, value):
"""Populate the ``short_title`` key.
Also populates the ``title_variants`` key through side effects.
"""
short_title = value.get('a')
title_variants = self.get('title_variants', [])
if value.get('u'):
short_title = value.get('u')
title_variant... | python | def short_title(self, key, value):
"""Populate the ``short_title`` key.
Also populates the ``title_variants`` key through side effects.
"""
short_title = value.get('a')
title_variants = self.get('title_variants', [])
if value.get('u'):
short_title = value.get('u')
title_variant... | [
"def",
"short_title",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"short_title",
"=",
"value",
".",
"get",
"(",
"'a'",
")",
"title_variants",
"=",
"self",
".",
"get",
"(",
"'title_variants'",
",",
"[",
"]",
")",
"if",
"value",
".",
"get",
"(",
... | Populate the ``short_title`` key.
Also populates the ``title_variants`` key through side effects. | [
"Populate",
"the",
"short_title",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/journals/rules.py#L203-L216 |
inspirehep/inspire-dojson | inspire_dojson/journals/rules.py | deleted | def deleted(self, key, value):
"""Populate the ``deleted`` key.
Also populates the ``book_series`` key through side effects.
"""
deleted = self.get('deleted')
book_series = self.get('book_series')
if not deleted:
normalized_a_values = [el.upper() for el in force_list(value.get('a'))]
... | python | def deleted(self, key, value):
"""Populate the ``deleted`` key.
Also populates the ``book_series`` key through side effects.
"""
deleted = self.get('deleted')
book_series = self.get('book_series')
if not deleted:
normalized_a_values = [el.upper() for el in force_list(value.get('a'))]
... | [
"def",
"deleted",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"deleted",
"=",
"self",
".",
"get",
"(",
"'deleted'",
")",
"book_series",
"=",
"self",
".",
"get",
"(",
"'book_series'",
")",
"if",
"not",
"deleted",
":",
"normalized_a_values",
"=",
"[... | Populate the ``deleted`` key.
Also populates the ``book_series`` key through side effects. | [
"Populate",
"the",
"deleted",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/journals/rules.py#L229-L249 |
inspirehep/inspire-dojson | inspire_dojson/jobs/rules.py | ranks | def ranks(self, key, value):
"""Populate the ``ranks`` key."""
return [normalize_rank(el) for el in force_list(value.get('a'))] | python | def ranks(self, key, value):
"""Populate the ``ranks`` key."""
return [normalize_rank(el) for el in force_list(value.get('a'))] | [
"def",
"ranks",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"[",
"normalize_rank",
"(",
"el",
")",
"for",
"el",
"in",
"force_list",
"(",
"value",
".",
"get",
"(",
"'a'",
")",
")",
"]"
] | Populate the ``ranks`` key. | [
"Populate",
"the",
"ranks",
"key",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/jobs/rules.py#L177-L179 |
walkr/oi | oi/core.py | BaseProgram.new_parser | def new_parser(self):
""" Create a command line argument parser
Add a few default flags, such as --version
for displaying the program version when invoked """
parser = argparse.ArgumentParser(description=self.description)
parser.add_argument(
'--version', help='show... | python | def new_parser(self):
""" Create a command line argument parser
Add a few default flags, such as --version
for displaying the program version when invoked """
parser = argparse.ArgumentParser(description=self.description)
parser.add_argument(
'--version', help='show... | [
"def",
"new_parser",
"(",
"self",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"self",
".",
"description",
")",
"parser",
".",
"add_argument",
"(",
"'--version'",
",",
"help",
"=",
"'show version and exit'",
",",
"defaul... | Create a command line argument parser
Add a few default flags, such as --version
for displaying the program version when invoked | [
"Create",
"a",
"command",
"line",
"argument",
"parser"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L48-L61 |
walkr/oi | oi/core.py | BaseProgram.add_command | def add_command(self, command, function, description=None):
""" Register a new function with a the name `command` and
`description` (which will be shown then help is invoked). """
self.registered[command] = {
'function': function, 'description': description
} | python | def add_command(self, command, function, description=None):
""" Register a new function with a the name `command` and
`description` (which will be shown then help is invoked). """
self.registered[command] = {
'function': function, 'description': description
} | [
"def",
"add_command",
"(",
"self",
",",
"command",
",",
"function",
",",
"description",
"=",
"None",
")",
":",
"self",
".",
"registered",
"[",
"command",
"]",
"=",
"{",
"'function'",
":",
"function",
",",
"'description'",
":",
"description",
"}"
] | Register a new function with a the name `command` and
`description` (which will be shown then help is invoked). | [
"Register",
"a",
"new",
"function",
"with",
"a",
"the",
"name",
"command",
"and",
"description",
"(",
"which",
"will",
"be",
"shown",
"then",
"help",
"is",
"invoked",
")",
"."
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L63-L69 |
walkr/oi | oi/core.py | BaseProgram.run | def run(self, args=None):
""" Parse command line arguments if necessary then run program.
By default this method will just take of the --version flag.
The logic for other flags should be handled by your subclass """
args = args or self.parser.parse_args()
if args.debug:
... | python | def run(self, args=None):
""" Parse command line arguments if necessary then run program.
By default this method will just take of the --version flag.
The logic for other flags should be handled by your subclass """
args = args or self.parser.parse_args()
if args.debug:
... | [
"def",
"run",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"args",
"=",
"args",
"or",
"self",
".",
"parser",
".",
"parse_args",
"(",
")",
"if",
"args",
".",
"debug",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"DEBUG"... | Parse command line arguments if necessary then run program.
By default this method will just take of the --version flag.
The logic for other flags should be handled by your subclass | [
"Parse",
"command",
"line",
"arguments",
"if",
"necessary",
"then",
"run",
"program",
".",
"By",
"default",
"this",
"method",
"will",
"just",
"take",
"of",
"the",
"--",
"version",
"flag",
"."
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L71-L84 |
walkr/oi | oi/core.py | Program.help_function | def help_function(self, command=None):
""" Show help for all available commands or just a single one """
if command:
return self.registered[command].get(
'description', 'No help available'
)
return ', '.join(sorted(self.registered)) | python | def help_function(self, command=None):
""" Show help for all available commands or just a single one """
if command:
return self.registered[command].get(
'description', 'No help available'
)
return ', '.join(sorted(self.registered)) | [
"def",
"help_function",
"(",
"self",
",",
"command",
"=",
"None",
")",
":",
"if",
"command",
":",
"return",
"self",
".",
"registered",
"[",
"command",
"]",
".",
"get",
"(",
"'description'",
",",
"'No help available'",
")",
"return",
"', '",
".",
"join",
... | Show help for all available commands or just a single one | [
"Show",
"help",
"for",
"all",
"available",
"commands",
"or",
"just",
"a",
"single",
"one"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L115-L121 |
walkr/oi | oi/core.py | Program.add_command | def add_command(self, command, function, description=None):
""" Register a new function for command """
super(Program, self).add_command(command, function, description)
self.service.register(command, function) | python | def add_command(self, command, function, description=None):
""" Register a new function for command """
super(Program, self).add_command(command, function, description)
self.service.register(command, function) | [
"def",
"add_command",
"(",
"self",
",",
"command",
",",
"function",
",",
"description",
"=",
"None",
")",
":",
"super",
"(",
"Program",
",",
"self",
")",
".",
"add_command",
"(",
"command",
",",
"function",
",",
"description",
")",
"self",
".",
"service"... | Register a new function for command | [
"Register",
"a",
"new",
"function",
"for",
"command"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L123-L126 |
walkr/oi | oi/core.py | Program.run | def run(self, args=None):
""" Parse comand line arguments/flags and run program """
args = args or self.parser.parse_args()
super(Program, self).run(args)
# Read configuration file if any
if args.config is not None:
filepath = args.config
self.config.rea... | python | def run(self, args=None):
""" Parse comand line arguments/flags and run program """
args = args or self.parser.parse_args()
super(Program, self).run(args)
# Read configuration file if any
if args.config is not None:
filepath = args.config
self.config.rea... | [
"def",
"run",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"args",
"=",
"args",
"or",
"self",
".",
"parser",
".",
"parse_args",
"(",
")",
"super",
"(",
"Program",
",",
"self",
")",
".",
"run",
"(",
"args",
")",
"# Read configuration file if any",
... | Parse comand line arguments/flags and run program | [
"Parse",
"comand",
"line",
"arguments",
"/",
"flags",
"and",
"run",
"program"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L128-L141 |
walkr/oi | oi/core.py | ClientWrapper.create_client | def create_client(self, addr, timeout):
""" Create client(s) based on addr """
def make(addr):
c = Client(addr)
c.socket._set_recv_timeout(timeout)
return c
if ',' in addr:
addrs = addr.split(',')
addrs = [a.strip() for a in addrs]
... | python | def create_client(self, addr, timeout):
""" Create client(s) based on addr """
def make(addr):
c = Client(addr)
c.socket._set_recv_timeout(timeout)
return c
if ',' in addr:
addrs = addr.split(',')
addrs = [a.strip() for a in addrs]
... | [
"def",
"create_client",
"(",
"self",
",",
"addr",
",",
"timeout",
")",
":",
"def",
"make",
"(",
"addr",
")",
":",
"c",
"=",
"Client",
"(",
"addr",
")",
"c",
".",
"socket",
".",
"_set_recv_timeout",
"(",
"timeout",
")",
"return",
"c",
"if",
"','",
"... | Create client(s) based on addr | [
"Create",
"client",
"(",
"s",
")",
"based",
"on",
"addr"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L151-L163 |
walkr/oi | oi/core.py | ClientWrapper._call_single | def _call_single(self, client, command, *args):
""" Call single """
try:
return client.call(command, *args)
except Exception as e:
return None, str(e) | python | def _call_single(self, client, command, *args):
""" Call single """
try:
return client.call(command, *args)
except Exception as e:
return None, str(e) | [
"def",
"_call_single",
"(",
"self",
",",
"client",
",",
"command",
",",
"*",
"args",
")",
":",
"try",
":",
"return",
"client",
".",
"call",
"(",
"command",
",",
"*",
"args",
")",
"except",
"Exception",
"as",
"e",
":",
"return",
"None",
",",
"str",
... | Call single | [
"Call",
"single"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L165-L170 |
walkr/oi | oi/core.py | ClientWrapper._call_multi | def _call_multi(self, clients, command, *args):
""" Call multi """
responses, errors = {}, {}
for addr, client in clients.items():
res, err = self._call_single(client, command, *args)
responses[addr] = res
errors[addr] = err
return responses, errors | python | def _call_multi(self, clients, command, *args):
""" Call multi """
responses, errors = {}, {}
for addr, client in clients.items():
res, err = self._call_single(client, command, *args)
responses[addr] = res
errors[addr] = err
return responses, errors | [
"def",
"_call_multi",
"(",
"self",
",",
"clients",
",",
"command",
",",
"*",
"args",
")",
":",
"responses",
",",
"errors",
"=",
"{",
"}",
",",
"{",
"}",
"for",
"addr",
",",
"client",
"in",
"clients",
".",
"items",
"(",
")",
":",
"res",
",",
"err"... | Call multi | [
"Call",
"multi"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L172-L179 |
walkr/oi | oi/core.py | ClientWrapper.call | def call(self, command, *args):
""" Call remote service(s) """
if isinstance(self.c, dict):
return self._call_multi(self.c, command, *args)
return self._call_single(self.c, command, *args) | python | def call(self, command, *args):
""" Call remote service(s) """
if isinstance(self.c, dict):
return self._call_multi(self.c, command, *args)
return self._call_single(self.c, command, *args) | [
"def",
"call",
"(",
"self",
",",
"command",
",",
"*",
"args",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"c",
",",
"dict",
")",
":",
"return",
"self",
".",
"_call_multi",
"(",
"self",
".",
"c",
",",
"command",
",",
"*",
"args",
")",
"return"... | Call remote service(s) | [
"Call",
"remote",
"service",
"(",
"s",
")"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L181-L185 |
walkr/oi | oi/core.py | ClientWrapper.close | def close(self):
""" Close socket(s) """
if isinstance(self.c, dict):
for client in self.c.values():
client.sock.close()
return
self.c.socket.close() | python | def close(self):
""" Close socket(s) """
if isinstance(self.c, dict):
for client in self.c.values():
client.sock.close()
return
self.c.socket.close() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"c",
",",
"dict",
")",
":",
"for",
"client",
"in",
"self",
".",
"c",
".",
"values",
"(",
")",
":",
"client",
".",
"sock",
".",
"close",
"(",
")",
"return",
"self",
"."... | Close socket(s) | [
"Close",
"socket",
"(",
"s",
")"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L191-L197 |
walkr/oi | oi/core.py | Response._show | def _show(self, res, err, prefix='', colored=False):
""" Show result or error """
if self.kind is 'local':
what = res if not err else err
print(what)
return
if self.kind is 'remote':
if colored:
red, green, reset = Fore.RED, Fore.... | python | def _show(self, res, err, prefix='', colored=False):
""" Show result or error """
if self.kind is 'local':
what = res if not err else err
print(what)
return
if self.kind is 'remote':
if colored:
red, green, reset = Fore.RED, Fore.... | [
"def",
"_show",
"(",
"self",
",",
"res",
",",
"err",
",",
"prefix",
"=",
"''",
",",
"colored",
"=",
"False",
")",
":",
"if",
"self",
".",
"kind",
"is",
"'local'",
":",
"what",
"=",
"res",
"if",
"not",
"err",
"else",
"err",
"print",
"(",
"what",
... | Show result or error | [
"Show",
"result",
"or",
"error"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L210-L227 |
walkr/oi | oi/core.py | CtlProgram.call | def call(self, command, *args):
""" Execute local OR remote command and show response """
if not command:
return
# Look for local methods first
try:
res = self.registered[command]['function'](self, *args)
return Response('local', res, None)
... | python | def call(self, command, *args):
""" Execute local OR remote command and show response """
if not command:
return
# Look for local methods first
try:
res = self.registered[command]['function'](self, *args)
return Response('local', res, None)
... | [
"def",
"call",
"(",
"self",
",",
"command",
",",
"*",
"args",
")",
":",
"if",
"not",
"command",
":",
"return",
"# Look for local methods first",
"try",
":",
"res",
"=",
"self",
".",
"registered",
"[",
"command",
"]",
"[",
"'function'",
"]",
"(",
"self",
... | Execute local OR remote command and show response | [
"Execute",
"local",
"OR",
"remote",
"command",
"and",
"show",
"response"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L267-L287 |
walkr/oi | oi/core.py | CtlProgram.parse_input | def parse_input(self, text):
""" Parse ctl user input. Double quotes are used
to group together multi words arguments. """
parts = util.split(text)
command = parts[0] if text and parts else None
command = command.lower() if command else None
args = parts[1:] if len(parts... | python | def parse_input(self, text):
""" Parse ctl user input. Double quotes are used
to group together multi words arguments. """
parts = util.split(text)
command = parts[0] if text and parts else None
command = command.lower() if command else None
args = parts[1:] if len(parts... | [
"def",
"parse_input",
"(",
"self",
",",
"text",
")",
":",
"parts",
"=",
"util",
".",
"split",
"(",
"text",
")",
"command",
"=",
"parts",
"[",
"0",
"]",
"if",
"text",
"and",
"parts",
"else",
"None",
"command",
"=",
"command",
".",
"lower",
"(",
")",... | Parse ctl user input. Double quotes are used
to group together multi words arguments. | [
"Parse",
"ctl",
"user",
"input",
".",
"Double",
"quotes",
"are",
"used",
"to",
"group",
"together",
"multi",
"words",
"arguments",
"."
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L289-L298 |
walkr/oi | oi/core.py | CtlProgram.loop | def loop(self):
""" Enter loop, read user input then run command. Repeat """
while True:
text = compat.input('ctl > ')
command, args = self.parse_input(text)
if not command:
continue
response = self.call(command, *args)
respons... | python | def loop(self):
""" Enter loop, read user input then run command. Repeat """
while True:
text = compat.input('ctl > ')
command, args = self.parse_input(text)
if not command:
continue
response = self.call(command, *args)
respons... | [
"def",
"loop",
"(",
"self",
")",
":",
"while",
"True",
":",
"text",
"=",
"compat",
".",
"input",
"(",
"'ctl > '",
")",
"command",
",",
"args",
"=",
"self",
".",
"parse_input",
"(",
"text",
")",
"if",
"not",
"command",
":",
"continue",
"response",
"="... | Enter loop, read user input then run command. Repeat | [
"Enter",
"loop",
"read",
"user",
"input",
"then",
"run",
"command",
".",
"Repeat"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/core.py#L300-L309 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/namespaces.py | namespace_for | def namespace_for(uri: Union[URIRef, Namespace, str]) -> str:
"""
Reverse namespace lookup. Note that returned namespace may not be unique
:param uri: namespace URI
:return: namespace
"""
uri = str(uri)
if uri not in namespaces.values():
namespaces[AnonNS().ns] = uri
return [k f... | python | def namespace_for(uri: Union[URIRef, Namespace, str]) -> str:
"""
Reverse namespace lookup. Note that returned namespace may not be unique
:param uri: namespace URI
:return: namespace
"""
uri = str(uri)
if uri not in namespaces.values():
namespaces[AnonNS().ns] = uri
return [k f... | [
"def",
"namespace_for",
"(",
"uri",
":",
"Union",
"[",
"URIRef",
",",
"Namespace",
",",
"str",
"]",
")",
"->",
"str",
":",
"uri",
"=",
"str",
"(",
"uri",
")",
"if",
"uri",
"not",
"in",
"namespaces",
".",
"values",
"(",
")",
":",
"namespaces",
"[",
... | Reverse namespace lookup. Note that returned namespace may not be unique
:param uri: namespace URI
:return: namespace | [
"Reverse",
"namespace",
"lookup",
".",
"Note",
"that",
"returned",
"namespace",
"may",
"not",
"be",
"unique",
":",
"param",
"uri",
":",
"namespace",
"URI",
":",
"return",
":",
"namespace"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/namespaces.py#L66-L75 |
walkr/oi | oi/util.py | split | def split(text):
""" Split text into arguments accounting for muti-word arguments
which are double quoted """
# Cleanup text
text = text.strip()
text = re.sub('\s+', ' ', text) # collpse multiple spaces
space, quote, parts = ' ', '"', []
part, quoted = '', False
for char in text:
... | python | def split(text):
""" Split text into arguments accounting for muti-word arguments
which are double quoted """
# Cleanup text
text = text.strip()
text = re.sub('\s+', ' ', text) # collpse multiple spaces
space, quote, parts = ' ', '"', []
part, quoted = '', False
for char in text:
... | [
"def",
"split",
"(",
"text",
")",
":",
"# Cleanup text",
"text",
"=",
"text",
".",
"strip",
"(",
")",
"text",
"=",
"re",
".",
"sub",
"(",
"'\\s+'",
",",
"' '",
",",
"text",
")",
"# collpse multiple spaces",
"space",
",",
"quote",
",",
"parts",
"=",
"... | Split text into arguments accounting for muti-word arguments
which are double quoted | [
"Split",
"text",
"into",
"arguments",
"accounting",
"for",
"muti",
"-",
"word",
"arguments",
"which",
"are",
"double",
"quoted"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/oi/util.py#L6-L51 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/rdflibformats.py | known_formats | def known_formats(use: Union[Serializer, Parser]=Serializer, include_mime_types: bool = False) -> List[str]:
""" Return a list of available formats in rdflib for the required task
:param use: task (typically Serializer or Parser)
:param include_mime_types: whether mime types are included in the return list
... | python | def known_formats(use: Union[Serializer, Parser]=Serializer, include_mime_types: bool = False) -> List[str]:
""" Return a list of available formats in rdflib for the required task
:param use: task (typically Serializer or Parser)
:param include_mime_types: whether mime types are included in the return list
... | [
"def",
"known_formats",
"(",
"use",
":",
"Union",
"[",
"Serializer",
",",
"Parser",
"]",
"=",
"Serializer",
",",
"include_mime_types",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"sorted",
"(",
"[",
"name",
"for",
"nam... | Return a list of available formats in rdflib for the required task
:param use: task (typically Serializer or Parser)
:param include_mime_types: whether mime types are included in the return list
:return: list of formats | [
"Return",
"a",
"list",
"of",
"available",
"formats",
"in",
"rdflib",
"for",
"the",
"required",
"task",
":",
"param",
"use",
":",
"task",
"(",
"typically",
"Serializer",
"or",
"Parser",
")",
":",
"param",
"include_mime_types",
":",
"whether",
"mime",
"types",... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/rdflibformats.py#L47-L54 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/signature.py | file_signature | def file_signature(file_name: str) -> Optional[Tuple]:
"""
Return an identity signature for file name
:param file_name: name of file
:return: mode, size, last modified time if file exists, otherwise none
"""
try:
st = os.stat(file_name)
except FileNotFoundError:
return None
... | python | def file_signature(file_name: str) -> Optional[Tuple]:
"""
Return an identity signature for file name
:param file_name: name of file
:return: mode, size, last modified time if file exists, otherwise none
"""
try:
st = os.stat(file_name)
except FileNotFoundError:
return None
... | [
"def",
"file_signature",
"(",
"file_name",
":",
"str",
")",
"->",
"Optional",
"[",
"Tuple",
"]",
":",
"try",
":",
"st",
"=",
"os",
".",
"stat",
"(",
"file_name",
")",
"except",
"FileNotFoundError",
":",
"return",
"None",
"return",
"stat",
".",
"S_IFMT",
... | Return an identity signature for file name
:param file_name: name of file
:return: mode, size, last modified time if file exists, otherwise none | [
"Return",
"an",
"identity",
"signature",
"for",
"file",
"name",
":",
"param",
"file_name",
":",
"name",
"of",
"file",
":",
"return",
":",
"mode",
"size",
"last",
"modified",
"time",
"if",
"file",
"exists",
"otherwise",
"none"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/signature.py#L53-L63 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/signature.py | url_signature | def url_signature(url: str) -> Optional[Tuple]:
"""
Return an identify signature for url
:param url: item to get signature for
:return: tuple containing last modified, length and, if present, etag
"""
request = urllib.request.Request(url)
request.get_method = lambda: 'HEAD'
response = No... | python | def url_signature(url: str) -> Optional[Tuple]:
"""
Return an identify signature for url
:param url: item to get signature for
:return: tuple containing last modified, length and, if present, etag
"""
request = urllib.request.Request(url)
request.get_method = lambda: 'HEAD'
response = No... | [
"def",
"url_signature",
"(",
"url",
":",
"str",
")",
"->",
"Optional",
"[",
"Tuple",
"]",
":",
"request",
"=",
"urllib",
".",
"request",
".",
"Request",
"(",
"url",
")",
"request",
".",
"get_method",
"=",
"lambda",
":",
"'HEAD'",
"response",
"=",
"None... | Return an identify signature for url
:param url: item to get signature for
:return: tuple containing last modified, length and, if present, etag | [
"Return",
"an",
"identify",
"signature",
"for",
"url",
":",
"param",
"url",
":",
"item",
"to",
"get",
"signature",
"for",
":",
"return",
":",
"tuple",
"containing",
"last",
"modified",
"length",
"and",
"if",
"present",
"etag"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/signature.py#L66-L79 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/signature.py | signature | def signature(name: str) -> Optional[Tuple]:
"""
Return the file or URL signature for name
:param name:
:return:
"""
return url_signature(name) if is_url(name) else file_signature(name) if is_file(name) else None | python | def signature(name: str) -> Optional[Tuple]:
"""
Return the file or URL signature for name
:param name:
:return:
"""
return url_signature(name) if is_url(name) else file_signature(name) if is_file(name) else None | [
"def",
"signature",
"(",
"name",
":",
"str",
")",
"->",
"Optional",
"[",
"Tuple",
"]",
":",
"return",
"url_signature",
"(",
"name",
")",
"if",
"is_url",
"(",
"name",
")",
"else",
"file_signature",
"(",
"name",
")",
"if",
"is_file",
"(",
"name",
")",
... | Return the file or URL signature for name
:param name:
:return: | [
"Return",
"the",
"file",
"or",
"URL",
"signature",
"for",
"name",
":",
"param",
"name",
":",
":",
"return",
":"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/signature.py#L82-L88 |
walkr/oi | setup.py | read_long_description | def read_long_description(readme_file):
""" Read package long description from README file """
try:
import pypandoc
except (ImportError, OSError) as e:
print('No pypandoc or pandoc: %s' % (e,))
if is_py3:
fh = open(readme_file, encoding='utf-8')
else:
... | python | def read_long_description(readme_file):
""" Read package long description from README file """
try:
import pypandoc
except (ImportError, OSError) as e:
print('No pypandoc or pandoc: %s' % (e,))
if is_py3:
fh = open(readme_file, encoding='utf-8')
else:
... | [
"def",
"read_long_description",
"(",
"readme_file",
")",
":",
"try",
":",
"import",
"pypandoc",
"except",
"(",
"ImportError",
",",
"OSError",
")",
"as",
"e",
":",
"print",
"(",
"'No pypandoc or pandoc: %s'",
"%",
"(",
"e",
",",
")",
")",
"if",
"is_py3",
":... | Read package long description from README file | [
"Read",
"package",
"long",
"description",
"from",
"README",
"file"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/setup.py#L17-L31 |
walkr/oi | setup.py | read_version | def read_version():
""" Read package version """
with open('./oi/version.py') as fh:
for line in fh:
if line.startswith('VERSION'):
return line.split('=')[1].strip().strip("'") | python | def read_version():
""" Read package version """
with open('./oi/version.py') as fh:
for line in fh:
if line.startswith('VERSION'):
return line.split('=')[1].strip().strip("'") | [
"def",
"read_version",
"(",
")",
":",
"with",
"open",
"(",
"'./oi/version.py'",
")",
"as",
"fh",
":",
"for",
"line",
"in",
"fh",
":",
"if",
"line",
".",
"startswith",
"(",
"'VERSION'",
")",
":",
"return",
"line",
".",
"split",
"(",
"'='",
")",
"[",
... | Read package version | [
"Read",
"package",
"version"
] | train | https://github.com/walkr/oi/blob/d9d8491d0bc920e493d8f716d6078762b8b2c6d3/setup.py#L34-L39 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/prettygraph.py | PrettyGraph.strip_prefixes | def strip_prefixes(g: Graph):
""" Remove the prefixes from the graph for aesthetics """
return re.sub(r'^@prefix .* .\n', '',
g.serialize(format="turtle").decode(),
flags=re.MULTILINE).strip() | python | def strip_prefixes(g: Graph):
""" Remove the prefixes from the graph for aesthetics """
return re.sub(r'^@prefix .* .\n', '',
g.serialize(format="turtle").decode(),
flags=re.MULTILINE).strip() | [
"def",
"strip_prefixes",
"(",
"g",
":",
"Graph",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r'^@prefix .* .\\n'",
",",
"''",
",",
"g",
".",
"serialize",
"(",
"format",
"=",
"\"turtle\"",
")",
".",
"decode",
"(",
")",
",",
"flags",
"=",
"re",
".",
... | Remove the prefixes from the graph for aesthetics | [
"Remove",
"the",
"prefixes",
"from",
"the",
"graph",
"for",
"aesthetics"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/prettygraph.py#L98-L102 |
BD2KOnFHIR/fhirtordf | fhirtordf/loaders/fhirresourceloader.py | FHIRResource.add_prefixes | def add_prefixes(self, nsmap: Dict[str, Namespace]) -> None:
"""
Add the required prefix definitions
:return:
"""
[self._g.bind(e[0], e[1]) for e in nsmap.items()] | python | def add_prefixes(self, nsmap: Dict[str, Namespace]) -> None:
"""
Add the required prefix definitions
:return:
"""
[self._g.bind(e[0], e[1]) for e in nsmap.items()] | [
"def",
"add_prefixes",
"(",
"self",
",",
"nsmap",
":",
"Dict",
"[",
"str",
",",
"Namespace",
"]",
")",
"->",
"None",
":",
"[",
"self",
".",
"_g",
".",
"bind",
"(",
"e",
"[",
"0",
"]",
",",
"e",
"[",
"1",
"]",
")",
"for",
"e",
"in",
"nsmap",
... | Add the required prefix definitions
:return: | [
"Add",
"the",
"required",
"prefix",
"definitions",
":",
"return",
":"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/loaders/fhirresourceloader.py#L132-L137 |
BD2KOnFHIR/fhirtordf | fhirtordf/loaders/fhirresourceloader.py | FHIRResource.add | def add(self, subj: Node, pred: URIRef, obj: Node) -> "FHIRResource":
"""
Shortcut to rdflib add function
:param subj:
:param pred:
:param obj:
:return: self for chaining
"""
self._g.add((subj, pred, obj))
return self | python | def add(self, subj: Node, pred: URIRef, obj: Node) -> "FHIRResource":
"""
Shortcut to rdflib add function
:param subj:
:param pred:
:param obj:
:return: self for chaining
"""
self._g.add((subj, pred, obj))
return self | [
"def",
"add",
"(",
"self",
",",
"subj",
":",
"Node",
",",
"pred",
":",
"URIRef",
",",
"obj",
":",
"Node",
")",
"->",
"\"FHIRResource\"",
":",
"self",
".",
"_g",
".",
"add",
"(",
"(",
"subj",
",",
"pred",
",",
"obj",
")",
")",
"return",
"self"
] | Shortcut to rdflib add function
:param subj:
:param pred:
:param obj:
:return: self for chaining | [
"Shortcut",
"to",
"rdflib",
"add",
"function",
":",
"param",
"subj",
":",
":",
"param",
"pred",
":",
":",
"param",
"obj",
":",
":",
"return",
":",
"self",
"for",
"chaining"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/loaders/fhirresourceloader.py#L146-L155 |
BD2KOnFHIR/fhirtordf | fhirtordf/loaders/fhirresourceloader.py | FHIRResource.add_value_node | def add_value_node(self, subj: Node, pred: URIRef, val: Union[JsonObj, str, List],
valuetype: Optional[URIRef]= None) -> None:
"""
Expand val according to the range of pred and add it to the graph
:param subj: graph subject
:param pred: graph predicate
:par... | python | def add_value_node(self, subj: Node, pred: URIRef, val: Union[JsonObj, str, List],
valuetype: Optional[URIRef]= None) -> None:
"""
Expand val according to the range of pred and add it to the graph
:param subj: graph subject
:param pred: graph predicate
:par... | [
"def",
"add_value_node",
"(",
"self",
",",
"subj",
":",
"Node",
",",
"pred",
":",
"URIRef",
",",
"val",
":",
"Union",
"[",
"JsonObj",
",",
"str",
",",
"List",
"]",
",",
"valuetype",
":",
"Optional",
"[",
"URIRef",
"]",
"=",
"None",
")",
"->",
"None... | Expand val according to the range of pred and add it to the graph
:param subj: graph subject
:param pred: graph predicate
:param val: JSON representation of target object
:param valuetype: predicate type if it can't be directly determined | [
"Expand",
"val",
"according",
"to",
"the",
"range",
"of",
"pred",
"and",
"add",
"it",
"to",
"the",
"graph",
":",
"param",
"subj",
":",
"graph",
"subject",
":",
"param",
"pred",
":",
"graph",
"predicate",
":",
"param",
"val",
":",
"JSON",
"representation"... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/loaders/fhirresourceloader.py#L157-L185 |
BD2KOnFHIR/fhirtordf | fhirtordf/loaders/fhirresourceloader.py | FHIRResource.add_reference | def add_reference(self, subj: Node, val: str) -> None:
"""
Add a fhir:link and RDF type arc if it can be determined
:param subj: reference subject
:param val: reference value
"""
match = FHIR_RESOURCE_RE.match(val)
ref_uri_str = res_type = None
if match:
... | python | def add_reference(self, subj: Node, val: str) -> None:
"""
Add a fhir:link and RDF type arc if it can be determined
:param subj: reference subject
:param val: reference value
"""
match = FHIR_RESOURCE_RE.match(val)
ref_uri_str = res_type = None
if match:
... | [
"def",
"add_reference",
"(",
"self",
",",
"subj",
":",
"Node",
",",
"val",
":",
"str",
")",
"->",
"None",
":",
"match",
"=",
"FHIR_RESOURCE_RE",
".",
"match",
"(",
"val",
")",
"ref_uri_str",
"=",
"res_type",
"=",
"None",
"if",
"match",
":",
"ref_uri_st... | Add a fhir:link and RDF type arc if it can be determined
:param subj: reference subject
:param val: reference value | [
"Add",
"a",
"fhir",
":",
"link",
"and",
"RDF",
"type",
"arc",
"if",
"it",
"can",
"be",
"determined",
":",
"param",
"subj",
":",
"reference",
"subject",
":",
"param",
"val",
":",
"reference",
"value"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/loaders/fhirresourceloader.py#L187-L207 |
BD2KOnFHIR/fhirtordf | fhirtordf/loaders/fhirresourceloader.py | FHIRResource.add_val | def add_val(self, subj: Node, pred: URIRef, json_obj: JsonObj, json_key: str,
valuetype: Optional[URIRef] = None) -> Optional[BNode]:
"""
Add the RDF representation of val to the graph as a target of subj, pred. Note that FHIR lists are
represented as a list of BNODE objects wit... | python | def add_val(self, subj: Node, pred: URIRef, json_obj: JsonObj, json_key: str,
valuetype: Optional[URIRef] = None) -> Optional[BNode]:
"""
Add the RDF representation of val to the graph as a target of subj, pred. Note that FHIR lists are
represented as a list of BNODE objects wit... | [
"def",
"add_val",
"(",
"self",
",",
"subj",
":",
"Node",
",",
"pred",
":",
"URIRef",
",",
"json_obj",
":",
"JsonObj",
",",
"json_key",
":",
"str",
",",
"valuetype",
":",
"Optional",
"[",
"URIRef",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"BNode"... | Add the RDF representation of val to the graph as a target of subj, pred. Note that FHIR lists are
represented as a list of BNODE objects with a fhir:index discrimanant
:param subj: graph subject
:param pred: predicate
:param json_obj: object containing json_key
:param json_key:... | [
"Add",
"the",
"RDF",
"representation",
"of",
"val",
"to",
"the",
"graph",
"as",
"a",
"target",
"of",
"subj",
"pred",
".",
"Note",
"that",
"FHIR",
"lists",
"are",
"represented",
"as",
"a",
"list",
"of",
"BNODE",
"objects",
"with",
"a",
"fhir",
":",
"ind... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/loaders/fhirresourceloader.py#L229-L292 |
BD2KOnFHIR/fhirtordf | fhirtordf/loaders/fhirresourceloader.py | FHIRResource.add_extension_val | def add_extension_val(self,
subj: Node,
json_obj:
Union[JsonObj, List[JsonObjTypes]],
key: str,
pred: Optional[URIRef] = None) -> None:
"""
Add any extensions for the supplie... | python | def add_extension_val(self,
subj: Node,
json_obj:
Union[JsonObj, List[JsonObjTypes]],
key: str,
pred: Optional[URIRef] = None) -> None:
"""
Add any extensions for the supplie... | [
"def",
"add_extension_val",
"(",
"self",
",",
"subj",
":",
"Node",
",",
"json_obj",
":",
"Union",
"[",
"JsonObj",
",",
"List",
"[",
"JsonObjTypes",
"]",
"]",
",",
"key",
":",
"str",
",",
"pred",
":",
"Optional",
"[",
"URIRef",
"]",
"=",
"None",
")",
... | Add any extensions for the supplied object. This can be called in following situations:
1) Single extended value
"key" : (value),
"_key" : {
"extension": [
{
"url": "http://...",
"value[x]... | [
"Add",
"any",
"extensions",
"for",
"the",
"supplied",
"object",
".",
"This",
"can",
"be",
"called",
"in",
"following",
"situations",
":",
"1",
")",
"Single",
"extended",
"value",
"key",
":",
"(",
"value",
")",
"_key",
":",
"{",
"extension",
":",
"[",
"... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/loaders/fhirresourceloader.py#L294-L362 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/fhirgraphutils.py | link | def link(g: Graph, subject: Node, predicate: URIRef) -> Tuple[Optional[URIRef], Optional[URIRef]]:
"""
Return the link URI and link type for subject and predicate
:param g: graph context
:param subject: subject of linke
:param predicate: link predicate
:return: URI and optional type URI. URI is... | python | def link(g: Graph, subject: Node, predicate: URIRef) -> Tuple[Optional[URIRef], Optional[URIRef]]:
"""
Return the link URI and link type for subject and predicate
:param g: graph context
:param subject: subject of linke
:param predicate: link predicate
:return: URI and optional type URI. URI is... | [
"def",
"link",
"(",
"g",
":",
"Graph",
",",
"subject",
":",
"Node",
",",
"predicate",
":",
"URIRef",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"URIRef",
"]",
",",
"Optional",
"[",
"URIRef",
"]",
"]",
":",
"link_node",
"=",
"g",
".",
"value",
"(",
... | Return the link URI and link type for subject and predicate
:param g: graph context
:param subject: subject of linke
:param predicate: link predicate
:return: URI and optional type URI. URI is None if not a link | [
"Return",
"the",
"link",
"URI",
"and",
"link",
"type",
"for",
"subject",
"and",
"predicate",
":",
"param",
"g",
":",
"graph",
"context",
":",
"param",
"subject",
":",
"subject",
"of",
"linke",
":",
"param",
"predicate",
":",
"link",
"predicate",
":",
"re... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/fhirgraphutils.py#L90-L104 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/fhirgraphutils.py | codeable_concept_code | def codeable_concept_code(g: Graph, subject: Node, predicate: URIRef, system: Optional[str]=None) \
-> List[CodeableConcept]:
"""
Return a list of CodeableConcept entries for the supplied subject and predicate in graph g
:param g: graph containing the data
:param subject: subject
:param pred... | python | def codeable_concept_code(g: Graph, subject: Node, predicate: URIRef, system: Optional[str]=None) \
-> List[CodeableConcept]:
"""
Return a list of CodeableConcept entries for the supplied subject and predicate in graph g
:param g: graph containing the data
:param subject: subject
:param pred... | [
"def",
"codeable_concept_code",
"(",
"g",
":",
"Graph",
",",
"subject",
":",
"Node",
",",
"predicate",
":",
"URIRef",
",",
"system",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"CodeableConcept",
"]",
":",
"# EXAMPLE:",
"# fhir... | Return a list of CodeableConcept entries for the supplied subject and predicate in graph g
:param g: graph containing the data
:param subject: subject
:param predicate: predicate
:param system: coding system. If present, only concepts in this system will be returned
:return: system, code and option... | [
"Return",
"a",
"list",
"of",
"CodeableConcept",
"entries",
"for",
"the",
"supplied",
"subject",
"and",
"predicate",
"in",
"graph",
"g",
":",
"param",
"g",
":",
"graph",
"containing",
"the",
"data",
":",
"param",
"subject",
":",
"subject",
":",
"param",
"pr... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/fhirgraphutils.py#L127-L159 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/fhirmetavoc.py | FHIRMetaVocEntry._to_str | def _to_str(uri: URIRef) -> str:
"""
Convert a FHIR style URI into a tag name to be used to retrieve data from a JSON representation
Example: http://hl7.org/fhir/Provenance.agent.whoReference --> whoReference
:param uri: URI to convert
:return: tag name
"""
local_... | python | def _to_str(uri: URIRef) -> str:
"""
Convert a FHIR style URI into a tag name to be used to retrieve data from a JSON representation
Example: http://hl7.org/fhir/Provenance.agent.whoReference --> whoReference
:param uri: URI to convert
:return: tag name
"""
local_... | [
"def",
"_to_str",
"(",
"uri",
":",
"URIRef",
")",
"->",
"str",
":",
"local_name",
"=",
"str",
"(",
"uri",
")",
".",
"replace",
"(",
"str",
"(",
"FHIR",
")",
",",
"''",
")",
"return",
"local_name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
... | Convert a FHIR style URI into a tag name to be used to retrieve data from a JSON representation
Example: http://hl7.org/fhir/Provenance.agent.whoReference --> whoReference
:param uri: URI to convert
:return: tag name | [
"Convert",
"a",
"FHIR",
"style",
"URI",
"into",
"a",
"tag",
"name",
"to",
"be",
"used",
"to",
"retrieve",
"data",
"from",
"a",
"JSON",
"representation",
"Example",
":",
"http",
":",
"//",
"hl7",
".",
"org",
"/",
"fhir",
"/",
"Provenance",
".",
"agent",... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/fhirmetavoc.py#L60-L68 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/fhirmetavoc.py | FHIRMetaVocEntry.predicates | def predicates(self) -> Dict[str, URIRef]:
"""
Return the tag names and corresponding URI's for all properties that can be associated with subject
:return: Map from tag name (JSON object identifier) to corresponding URI
"""
rval = dict()
for parent in self._o.objects(self... | python | def predicates(self) -> Dict[str, URIRef]:
"""
Return the tag names and corresponding URI's for all properties that can be associated with subject
:return: Map from tag name (JSON object identifier) to corresponding URI
"""
rval = dict()
for parent in self._o.objects(self... | [
"def",
"predicates",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"URIRef",
"]",
":",
"rval",
"=",
"dict",
"(",
")",
"for",
"parent",
"in",
"self",
".",
"_o",
".",
"objects",
"(",
"self",
".",
"_subj",
",",
"RDFS",
".",
"subClassOf",
")",
":"... | Return the tag names and corresponding URI's for all properties that can be associated with subject
:return: Map from tag name (JSON object identifier) to corresponding URI | [
"Return",
"the",
"tag",
"names",
"and",
"corresponding",
"URI",
"s",
"for",
"all",
"properties",
"that",
"can",
"be",
"associated",
"with",
"subject",
":",
"return",
":",
"Map",
"from",
"tag",
"name",
"(",
"JSON",
"object",
"identifier",
")",
"to",
"corres... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/fhirmetavoc.py#L70-L81 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/fhirmetavoc.py | FHIRMetaVocEntry.predicate_type | def predicate_type(self, pred: URIRef) -> URIRef:
"""
Return the type of pred
:param pred: predicate to map
:return:
"""
return self._o.value(pred, RDFS.range) | python | def predicate_type(self, pred: URIRef) -> URIRef:
"""
Return the type of pred
:param pred: predicate to map
:return:
"""
return self._o.value(pred, RDFS.range) | [
"def",
"predicate_type",
"(",
"self",
",",
"pred",
":",
"URIRef",
")",
"->",
"URIRef",
":",
"return",
"self",
".",
"_o",
".",
"value",
"(",
"pred",
",",
"RDFS",
".",
"range",
")"
] | Return the type of pred
:param pred: predicate to map
:return: | [
"Return",
"the",
"type",
"of",
"pred",
":",
"param",
"pred",
":",
"predicate",
"to",
"map",
":",
"return",
":"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/fhirmetavoc.py#L83-L89 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/fhirmetavoc.py | FHIRMetaVocEntry.is_valid | def is_valid(self, t: URIRef) -> bool:
"""
Raise an exception if 't' is unrecognized
:param t: metadata URI
"""
if not self.has_type(t):
raise TypeError("Unrecognized FHIR type: {}".format(t))
return True | python | def is_valid(self, t: URIRef) -> bool:
"""
Raise an exception if 't' is unrecognized
:param t: metadata URI
"""
if not self.has_type(t):
raise TypeError("Unrecognized FHIR type: {}".format(t))
return True | [
"def",
"is_valid",
"(",
"self",
",",
"t",
":",
"URIRef",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"has_type",
"(",
"t",
")",
":",
"raise",
"TypeError",
"(",
"\"Unrecognized FHIR type: {}\"",
".",
"format",
"(",
"t",
")",
")",
"return",
"True"
... | Raise an exception if 't' is unrecognized
:param t: metadata URI | [
"Raise",
"an",
"exception",
"if",
"t",
"is",
"unrecognized",
":",
"param",
"t",
":",
"metadata",
"URI"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/fhirmetavoc.py#L94-L101 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/fhirmetavoc.py | FHIRMetaVocEntry.is_primitive | def is_primitive(self, t: URIRef) -> bool:
"""
Determine whether type "t" is a FHIR primitive type
:param t: type to test
:return:
"""
return FHIR.Primitive in self._o.objects(t, RDFS.subClassOf) | python | def is_primitive(self, t: URIRef) -> bool:
"""
Determine whether type "t" is a FHIR primitive type
:param t: type to test
:return:
"""
return FHIR.Primitive in self._o.objects(t, RDFS.subClassOf) | [
"def",
"is_primitive",
"(",
"self",
",",
"t",
":",
"URIRef",
")",
"->",
"bool",
":",
"return",
"FHIR",
".",
"Primitive",
"in",
"self",
".",
"_o",
".",
"objects",
"(",
"t",
",",
"RDFS",
".",
"subClassOf",
")"
] | Determine whether type "t" is a FHIR primitive type
:param t: type to test
:return: | [
"Determine",
"whether",
"type",
"t",
"is",
"a",
"FHIR",
"primitive",
"type",
":",
"param",
"t",
":",
"type",
"to",
"test",
":",
"return",
":"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/fhirmetavoc.py#L103-L109 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/fhirmetavoc.py | FHIRMetaVocEntry.value_predicate_to_type | def value_predicate_to_type(self, value_pred: str) -> URIRef:
"""
Convert a predicate in the form of "fhir:[...].value[type] to fhir:type, covering the downshift on the
first character if necessary
:param value_pred: Predicate associated with the value
:return: corresponding type... | python | def value_predicate_to_type(self, value_pred: str) -> URIRef:
"""
Convert a predicate in the form of "fhir:[...].value[type] to fhir:type, covering the downshift on the
first character if necessary
:param value_pred: Predicate associated with the value
:return: corresponding type... | [
"def",
"value_predicate_to_type",
"(",
"self",
",",
"value_pred",
":",
"str",
")",
"->",
"URIRef",
":",
"if",
"value_pred",
".",
"startswith",
"(",
"'value'",
")",
":",
"vp_datatype",
"=",
"value_pred",
".",
"replace",
"(",
"'value'",
",",
"''",
")",
"if",... | Convert a predicate in the form of "fhir:[...].value[type] to fhir:type, covering the downshift on the
first character if necessary
:param value_pred: Predicate associated with the value
:return: corresponding type or None if not found | [
"Convert",
"a",
"predicate",
"in",
"the",
"form",
"of",
"fhir",
":",
"[",
"...",
"]",
".",
"value",
"[",
"type",
"]",
"to",
"fhir",
":",
"type",
"covering",
"the",
"downshift",
"on",
"the",
"first",
"character",
"if",
"necessary",
":",
"param",
"value_... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/fhirmetavoc.py#L111-L128 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/fhirmetavoc.py | FHIRMetaVocEntry.is_atom | def is_atom(self, pred: URIRef) -> bool:
"""
Determine whether predicate is an 'atomic' type -- i.e it doesn't use a FHIR value representation
:param pred: type to test
:return:
"""
if not self.has_type(pred):
if '.value' in str(pred): # syntheti... | python | def is_atom(self, pred: URIRef) -> bool:
"""
Determine whether predicate is an 'atomic' type -- i.e it doesn't use a FHIR value representation
:param pred: type to test
:return:
"""
if not self.has_type(pred):
if '.value' in str(pred): # syntheti... | [
"def",
"is_atom",
"(",
"self",
",",
"pred",
":",
"URIRef",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"has_type",
"(",
"pred",
")",
":",
"if",
"'.value'",
"in",
"str",
"(",
"pred",
")",
":",
"# synthetic values (valueString, valueDate, ...)",
"retur... | Determine whether predicate is an 'atomic' type -- i.e it doesn't use a FHIR value representation
:param pred: type to test
:return: | [
"Determine",
"whether",
"predicate",
"is",
"an",
"atomic",
"type",
"--",
"i",
".",
"e",
"it",
"doesn",
"t",
"use",
"a",
"FHIR",
"value",
"representation",
":",
"param",
"pred",
":",
"type",
"to",
"test",
":",
"return",
":"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/fhirmetavoc.py#L130-L141 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/fhirmetavoc.py | FHIRMetaVocEntry.primitive_datatype | def primitive_datatype(self, t: URIRef) -> Optional[URIRef]:
"""
Return the data type for primitive type t, if any
:param t: type
:return: corresponding data type
"""
for sco in self._o.objects(t, RDFS.subClassOf):
sco_type = self._o.value(sco, RDF.type)
... | python | def primitive_datatype(self, t: URIRef) -> Optional[URIRef]:
"""
Return the data type for primitive type t, if any
:param t: type
:return: corresponding data type
"""
for sco in self._o.objects(t, RDFS.subClassOf):
sco_type = self._o.value(sco, RDF.type)
... | [
"def",
"primitive_datatype",
"(",
"self",
",",
"t",
":",
"URIRef",
")",
"->",
"Optional",
"[",
"URIRef",
"]",
":",
"for",
"sco",
"in",
"self",
".",
"_o",
".",
"objects",
"(",
"t",
",",
"RDFS",
".",
"subClassOf",
")",
":",
"sco_type",
"=",
"self",
"... | Return the data type for primitive type t, if any
:param t: type
:return: corresponding data type | [
"Return",
"the",
"data",
"type",
"for",
"primitive",
"type",
"t",
"if",
"any",
":",
"param",
"t",
":",
"type",
":",
"return",
":",
"corresponding",
"data",
"type"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/fhirmetavoc.py#L143-L159 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/fhirmetavoc.py | FHIRMetaVocEntry.primitive_datatype_nostring | def primitive_datatype_nostring(self, t: URIRef, v: Optional[str] = None) -> Optional[URIRef]:
"""
Return the data type for primitive type t, if any, defaulting string to no type
:param t: type
:param v: value - for munging dates if we're doing FHIR official output
:return: corre... | python | def primitive_datatype_nostring(self, t: URIRef, v: Optional[str] = None) -> Optional[URIRef]:
"""
Return the data type for primitive type t, if any, defaulting string to no type
:param t: type
:param v: value - for munging dates if we're doing FHIR official output
:return: corre... | [
"def",
"primitive_datatype_nostring",
"(",
"self",
",",
"t",
":",
"URIRef",
",",
"v",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"URIRef",
"]",
":",
"vt",
"=",
"self",
".",
"primitive_datatype",
"(",
"t",
")",
"if",
"s... | Return the data type for primitive type t, if any, defaulting string to no type
:param t: type
:param v: value - for munging dates if we're doing FHIR official output
:return: corresponding data type | [
"Return",
"the",
"data",
"type",
"for",
"primitive",
"type",
"t",
"if",
"any",
"defaulting",
"string",
"to",
"no",
"type",
":",
"param",
"t",
":",
"type",
":",
"param",
"v",
":",
"value",
"-",
"for",
"munging",
"dates",
"if",
"we",
"re",
"doing",
"FH... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/fhirmetavoc.py#L161-L175 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/picklejar.py | _PickleJar.add | def add(self, name: str, sig: Tuple, obj: object) -> None:
"""
Add a file to the cache
:param name: name of the object to be pickled
:param sig: signature for object
:param obj: object to pickle
"""
if self._cache_directory is not None:
if name in self... | python | def add(self, name: str, sig: Tuple, obj: object) -> None:
"""
Add a file to the cache
:param name: name of the object to be pickled
:param sig: signature for object
:param obj: object to pickle
"""
if self._cache_directory is not None:
if name in self... | [
"def",
"add",
"(",
"self",
",",
"name",
":",
"str",
",",
"sig",
":",
"Tuple",
",",
"obj",
":",
"object",
")",
"->",
"None",
":",
"if",
"self",
".",
"_cache_directory",
"is",
"not",
"None",
":",
"if",
"name",
"in",
"self",
".",
"_cache",
":",
"os"... | Add a file to the cache
:param name: name of the object to be pickled
:param sig: signature for object
:param obj: object to pickle | [
"Add",
"a",
"file",
"to",
"the",
"cache",
":",
"param",
"name",
":",
"name",
"of",
"the",
"object",
"to",
"be",
"pickled",
":",
"param",
"sig",
":",
"signature",
"for",
"object",
":",
"param",
"obj",
":",
"object",
"to",
"pickle"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/picklejar.py#L91-L105 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/picklejar.py | _PickleJar.get | def get(self, name: str, sig: Tuple) -> Optional[object]:
"""
Return the object representing name if it is cached
:param name: name of object
:param sig: unique signature of object
:return: object if exists and signature matches
"""
if name not in self._cache:
... | python | def get(self, name: str, sig: Tuple) -> Optional[object]:
"""
Return the object representing name if it is cached
:param name: name of object
:param sig: unique signature of object
:return: object if exists and signature matches
"""
if name not in self._cache:
... | [
"def",
"get",
"(",
"self",
",",
"name",
":",
"str",
",",
"sig",
":",
"Tuple",
")",
"->",
"Optional",
"[",
"object",
"]",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_cache",
":",
"return",
"None",
"if",
"self",
".",
"_cache",
"[",
"name",
"]",
... | Return the object representing name if it is cached
:param name: name of object
:param sig: unique signature of object
:return: object if exists and signature matches | [
"Return",
"the",
"object",
"representing",
"name",
"if",
"it",
"is",
"cached",
":",
"param",
"name",
":",
"name",
"of",
"object",
":",
"param",
"sig",
":",
"unique",
"signature",
"of",
"object",
":",
"return",
":",
"object",
"if",
"exists",
"and",
"signa... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/picklejar.py#L107-L121 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/picklejar.py | _PickleJar.clear | def clear(self) -> None:
"""
Clear all cache entries for directory and, if it is a 'pure' directory, remove the directory itself
"""
if self._cache_directory is not None:
# Safety - if there isn't a cache directory file, this probably isn't a valid cache
assert os... | python | def clear(self) -> None:
"""
Clear all cache entries for directory and, if it is a 'pure' directory, remove the directory itself
"""
if self._cache_directory is not None:
# Safety - if there isn't a cache directory file, this probably isn't a valid cache
assert os... | [
"def",
"clear",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_cache_directory",
"is",
"not",
"None",
":",
"# Safety - if there isn't a cache directory file, this probably isn't a valid cache",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",... | Clear all cache entries for directory and, if it is a 'pure' directory, remove the directory itself | [
"Clear",
"all",
"cache",
"entries",
"for",
"directory",
"and",
"if",
"it",
"is",
"a",
"pure",
"directory",
"remove",
"the",
"directory",
"itself"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/picklejar.py#L135-L148 |
BD2KOnFHIR/fhirtordf | fhirtordf/loaders/fhirjsonloader.py | fhir_json_to_rdf | def fhir_json_to_rdf(json_fname: str,
base_uri: str = "http://hl7.org/fhir/",
target_graph: Optional[Graph] = None,
add_ontology_header: bool = True,
do_continuations: bool = True,
replace_narrative_text: bool = Fal... | python | def fhir_json_to_rdf(json_fname: str,
base_uri: str = "http://hl7.org/fhir/",
target_graph: Optional[Graph] = None,
add_ontology_header: bool = True,
do_continuations: bool = True,
replace_narrative_text: bool = Fal... | [
"def",
"fhir_json_to_rdf",
"(",
"json_fname",
":",
"str",
",",
"base_uri",
":",
"str",
"=",
"\"http://hl7.org/fhir/\"",
",",
"target_graph",
":",
"Optional",
"[",
"Graph",
"]",
"=",
"None",
",",
"add_ontology_header",
":",
"bool",
"=",
"True",
",",
"do_continu... | Convert a FHIR JSON resource image to RDF
:param json_fname: Name or URI of the file to convert
:param base_uri: Base URI to use for relative references.
:param target_graph: If supplied, add RDF to this graph. If not, start with an empty graph.
:param add_ontology_header: True means add owl:Ontology ... | [
"Convert",
"a",
"FHIR",
"JSON",
"resource",
"image",
"to",
"RDF",
":",
"param",
"json_fname",
":",
"Name",
"or",
"URI",
"of",
"the",
"file",
"to",
"convert",
":",
"param",
"base_uri",
":",
"Base",
"URI",
"to",
"use",
"for",
"relative",
"references",
".",... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/loaders/fhirjsonloader.py#L38-L88 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/rdfcompare.py | subj_pred_idx_to_uri | def subj_pred_idx_to_uri(s: URIRef, p: URIRef, idx: Optional[int] = None) -> URIRef:
""" Convert FHIR subject, predicate and entry index into a URI. The resulting element can be substituted
for the name of the target BNODE
:param s: Subject URI (e.g. "fhir:Patient/f201", "fhir:Patient/f201.Patient.identifi... | python | def subj_pred_idx_to_uri(s: URIRef, p: URIRef, idx: Optional[int] = None) -> URIRef:
""" Convert FHIR subject, predicate and entry index into a URI. The resulting element can be substituted
for the name of the target BNODE
:param s: Subject URI (e.g. "fhir:Patient/f201", "fhir:Patient/f201.Patient.identifi... | [
"def",
"subj_pred_idx_to_uri",
"(",
"s",
":",
"URIRef",
",",
"p",
":",
"URIRef",
",",
"idx",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
"->",
"URIRef",
":",
"return",
"URIRef",
"(",
"str",
"(",
"s",
")",
"+",
"'.'",
"+",
"str",
"(",
"p",... | Convert FHIR subject, predicate and entry index into a URI. The resulting element can be substituted
for the name of the target BNODE
:param s: Subject URI (e.g. "fhir:Patient/f201", "fhir:Patient/f201.Patient.identifier_0", ...)
:param p: Predicate URI (e.g. "fhir:Patient.identifier", "fhir.Identifier.use... | [
"Convert",
"FHIR",
"subject",
"predicate",
"and",
"entry",
"index",
"into",
"a",
"URI",
".",
"The",
"resulting",
"element",
"can",
"be",
"substituted",
"for",
"the",
"name",
"of",
"the",
"target",
"BNODE",
":",
"param",
"s",
":",
"Subject",
"URI",
"(",
"... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/rdfcompare.py#L38-L46 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/rdfcompare.py | map_node | def map_node(s: Node, sk_s: URIRef, gin: Graph, gout: Graph) -> None:
"""
Transform the BNode whose subject is s into its equivalent, replacing s with its 'skolemized' equivalent
:param s: Actual subject
:param sk_s: Equivalent URI of subject in output graph
:param gin: Input graph
:param gout: ... | python | def map_node(s: Node, sk_s: URIRef, gin: Graph, gout: Graph) -> None:
"""
Transform the BNode whose subject is s into its equivalent, replacing s with its 'skolemized' equivalent
:param s: Actual subject
:param sk_s: Equivalent URI of subject in output graph
:param gin: Input graph
:param gout: ... | [
"def",
"map_node",
"(",
"s",
":",
"Node",
",",
"sk_s",
":",
"URIRef",
",",
"gin",
":",
"Graph",
",",
"gout",
":",
"Graph",
")",
"->",
"None",
":",
"for",
"p",
",",
"o",
"in",
"gin",
".",
"predicate_objects",
"(",
"s",
")",
":",
"if",
"not",
"is... | Transform the BNode whose subject is s into its equivalent, replacing s with its 'skolemized' equivalent
:param s: Actual subject
:param sk_s: Equivalent URI of subject in output graph
:param gin: Input graph
:param gout: Output graph | [
"Transform",
"the",
"BNode",
"whose",
"subject",
"is",
"s",
"into",
"its",
"equivalent",
"replacing",
"s",
"with",
"its",
"skolemized",
"equivalent",
":",
"param",
"s",
":",
"Actual",
"subject",
":",
"param",
"sk_s",
":",
"Equivalent",
"URI",
"of",
"subject"... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/rdfcompare.py#L49-L63 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/rdfcompare.py | skolemize | def skolemize(gin: Graph) -> Graph:
"""
Replace all of the blank nodes in graph gin with FHIR paths
:param gin: input graph
:return: output graph
"""
gout = Graph()
# Emit any unreferenced subject BNodes (boxes)
anon_subjs = [s for s in gin.subjects() if isinstance(s, BNode) and len([gi... | python | def skolemize(gin: Graph) -> Graph:
"""
Replace all of the blank nodes in graph gin with FHIR paths
:param gin: input graph
:return: output graph
"""
gout = Graph()
# Emit any unreferenced subject BNodes (boxes)
anon_subjs = [s for s in gin.subjects() if isinstance(s, BNode) and len([gi... | [
"def",
"skolemize",
"(",
"gin",
":",
"Graph",
")",
"->",
"Graph",
":",
"gout",
"=",
"Graph",
"(",
")",
"# Emit any unreferenced subject BNodes (boxes)",
"anon_subjs",
"=",
"[",
"s",
"for",
"s",
"in",
"gin",
".",
"subjects",
"(",
")",
"if",
"isinstance",
"(... | Replace all of the blank nodes in graph gin with FHIR paths
:param gin: input graph
:return: output graph | [
"Replace",
"all",
"of",
"the",
"blank",
"nodes",
"in",
"graph",
"gin",
"with",
"FHIR",
"paths",
":",
"param",
"gin",
":",
"input",
"graph",
":",
"return",
":",
"output",
"graph"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/rdfcompare.py#L66-L86 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/rdfcompare.py | complete_definition | def complete_definition(subj: Node,
source_graph: Graph,
target_graph: Optional[Graph]=None) -> PrettyGraph:
"""
Return the transitive closure of subject.
:param subj: URI or BNode for subject
:param source_graph: Graph containing defininition
:param t... | python | def complete_definition(subj: Node,
source_graph: Graph,
target_graph: Optional[Graph]=None) -> PrettyGraph:
"""
Return the transitive closure of subject.
:param subj: URI or BNode for subject
:param source_graph: Graph containing defininition
:param t... | [
"def",
"complete_definition",
"(",
"subj",
":",
"Node",
",",
"source_graph",
":",
"Graph",
",",
"target_graph",
":",
"Optional",
"[",
"Graph",
"]",
"=",
"None",
")",
"->",
"PrettyGraph",
":",
"if",
"target_graph",
"is",
"None",
":",
"target_graph",
"=",
"P... | Return the transitive closure of subject.
:param subj: URI or BNode for subject
:param source_graph: Graph containing defininition
:param target_graph: return graph (for recursion)
:return: target_graph | [
"Return",
"the",
"transitive",
"closure",
"of",
"subject",
".",
":",
"param",
"subj",
":",
"URI",
"or",
"BNode",
"for",
"subject",
":",
"param",
"source_graph",
":",
"Graph",
"containing",
"defininition",
":",
"param",
"target_graph",
":",
"return",
"graph",
... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/rdfcompare.py#L89-L105 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/rdfcompare.py | dump_nt_sorted | def dump_nt_sorted(g: Graph) -> List[str]:
"""
Dump graph g in a sorted n3 format
:param g: graph to dump
:return: stringified representation of g
"""
return [l.decode('ascii') for l in sorted(g.serialize(format='nt').splitlines()) if l] | python | def dump_nt_sorted(g: Graph) -> List[str]:
"""
Dump graph g in a sorted n3 format
:param g: graph to dump
:return: stringified representation of g
"""
return [l.decode('ascii') for l in sorted(g.serialize(format='nt').splitlines()) if l] | [
"def",
"dump_nt_sorted",
"(",
"g",
":",
"Graph",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"l",
".",
"decode",
"(",
"'ascii'",
")",
"for",
"l",
"in",
"sorted",
"(",
"g",
".",
"serialize",
"(",
"format",
"=",
"'nt'",
")",
".",
"split... | Dump graph g in a sorted n3 format
:param g: graph to dump
:return: stringified representation of g | [
"Dump",
"graph",
"g",
"in",
"a",
"sorted",
"n3",
"format",
":",
"param",
"g",
":",
"graph",
"to",
"dump",
":",
"return",
":",
"stringified",
"representation",
"of",
"g"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/rdfcompare.py#L108-L114 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/rdfcompare.py | rdf_compare | def rdf_compare(g1: Graph, g2: Graph, ignore_owl_version: bool=False, ignore_type_arcs: bool = False,
compare_filter: Optional[Callable[[Graph, Graph, Graph], None]]=None) -> str:
"""
Compare graph g1 and g2
:param g1: first graph
:param g2: second graph
:param ignore_owl_version:
... | python | def rdf_compare(g1: Graph, g2: Graph, ignore_owl_version: bool=False, ignore_type_arcs: bool = False,
compare_filter: Optional[Callable[[Graph, Graph, Graph], None]]=None) -> str:
"""
Compare graph g1 and g2
:param g1: first graph
:param g2: second graph
:param ignore_owl_version:
... | [
"def",
"rdf_compare",
"(",
"g1",
":",
"Graph",
",",
"g2",
":",
"Graph",
",",
"ignore_owl_version",
":",
"bool",
"=",
"False",
",",
"ignore_type_arcs",
":",
"bool",
"=",
"False",
",",
"compare_filter",
":",
"Optional",
"[",
"Callable",
"[",
"[",
"Graph",
... | Compare graph g1 and g2
:param g1: first graph
:param g2: second graph
:param ignore_owl_version:
:param ignore_type_arcs:
:param compare_filter: Final adjustment for graph difference. Used, for example, to deal with FHIR decimal problems.
:return: List of differences as printable lines or blank... | [
"Compare",
"graph",
"g1",
"and",
"g2",
":",
"param",
"g1",
":",
"first",
"graph",
":",
"param",
"g2",
":",
"second",
"graph",
":",
"param",
"ignore_owl_version",
":",
":",
"param",
"ignore_type_arcs",
":",
":",
"param",
"compare_filter",
":",
"Final",
"adj... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/rdfcompare.py#L117-L169 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhirtordf.py | proc_file | def proc_file(infile: str, outfile: str, opts: Namespace) -> bool:
"""
Process infile.
:param infile: input file to be processed
:param outfile: target output file.
:param opts:
:return:
"""
g = fhir_json_to_rdf(infile, opts.uribase, opts.graph, add_ontology_header=not opts.noontology,
... | python | def proc_file(infile: str, outfile: str, opts: Namespace) -> bool:
"""
Process infile.
:param infile: input file to be processed
:param outfile: target output file.
:param opts:
:return:
"""
g = fhir_json_to_rdf(infile, opts.uribase, opts.graph, add_ontology_header=not opts.noontology,
... | [
"def",
"proc_file",
"(",
"infile",
":",
"str",
",",
"outfile",
":",
"str",
",",
"opts",
":",
"Namespace",
")",
"->",
"bool",
":",
"g",
"=",
"fhir_json_to_rdf",
"(",
"infile",
",",
"opts",
".",
"uribase",
",",
"opts",
".",
"graph",
",",
"add_ontology_he... | Process infile.
:param infile: input file to be processed
:param outfile: target output file.
:param opts:
:return: | [
"Process",
"infile",
".",
":",
"param",
"infile",
":",
"input",
"file",
"to",
"be",
"processed",
":",
"param",
"outfile",
":",
"target",
"output",
"file",
".",
":",
"param",
"opts",
":",
":",
"return",
":"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhirtordf.py#L76-L95 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhirtordf.py | file_filter | def file_filter(ifn: str, indir: str, opts: Namespace) -> bool:
"""
Determine whether to process ifn. We con't process:
1) Anything in a directory having a path element that begins with "_"
2) Really, really big files
3) Temporary lists of know errors
:param ifn: input file name
... | python | def file_filter(ifn: str, indir: str, opts: Namespace) -> bool:
"""
Determine whether to process ifn. We con't process:
1) Anything in a directory having a path element that begins with "_"
2) Really, really big files
3) Temporary lists of know errors
:param ifn: input file name
... | [
"def",
"file_filter",
"(",
"ifn",
":",
"str",
",",
"indir",
":",
"str",
",",
"opts",
":",
"Namespace",
")",
"->",
"bool",
":",
"# If it looks like we're processing a URL as an input file, skip the suffix check",
"if",
"'://'",
"in",
"ifn",
":",
"return",
"True",
"... | Determine whether to process ifn. We con't process:
1) Anything in a directory having a path element that begins with "_"
2) Really, really big files
3) Temporary lists of know errors
:param ifn: input file name
:param indir: input directory
:param opts: argparse options
:return... | [
"Determine",
"whether",
"to",
"process",
"ifn",
".",
"We",
"con",
"t",
"process",
":",
"1",
")",
"Anything",
"in",
"a",
"directory",
"having",
"a",
"path",
"element",
"that",
"begins",
"with",
"_",
"2",
")",
"Really",
"really",
"big",
"files",
"3",
")"... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhirtordf.py#L105-L133 |
BD2KOnFHIR/fhirtordf | fhirtordf/fhirtordf.py | fhirtordf | def fhirtordf(argv: List[str], default_exit: bool = True) -> bool:
""" Entry point for command line utility """
dlp = dirlistproc.DirectoryListProcessor(argv,
description="Convert FHIR JSON into RDF",
infile_suffix=".json"... | python | def fhirtordf(argv: List[str], default_exit: bool = True) -> bool:
""" Entry point for command line utility """
dlp = dirlistproc.DirectoryListProcessor(argv,
description="Convert FHIR JSON into RDF",
infile_suffix=".json"... | [
"def",
"fhirtordf",
"(",
"argv",
":",
"List",
"[",
"str",
"]",
",",
"default_exit",
":",
"bool",
"=",
"True",
")",
"->",
"bool",
":",
"dlp",
"=",
"dirlistproc",
".",
"DirectoryListProcessor",
"(",
"argv",
",",
"description",
"=",
"\"Convert FHIR JSON into RD... | Entry point for command line utility | [
"Entry",
"point",
"for",
"command",
"line",
"utility"
] | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhirtordf.py#L162-L202 |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/uriutils.py | parse_fhir_resource_uri | def parse_fhir_resource_uri(uri: Union[URIRef, str]) -> FHIR_RESOURCE:
"""
Use the FHIR Regular Expression for Resource URI's to determine the namespace and type
of a given URI. As an example, "http://hl7.org/fhir/Patient/p123" maps to the tuple
``('Patient', 'http://hl7.org/fhir')
:param uri: UR... | python | def parse_fhir_resource_uri(uri: Union[URIRef, str]) -> FHIR_RESOURCE:
"""
Use the FHIR Regular Expression for Resource URI's to determine the namespace and type
of a given URI. As an example, "http://hl7.org/fhir/Patient/p123" maps to the tuple
``('Patient', 'http://hl7.org/fhir')
:param uri: UR... | [
"def",
"parse_fhir_resource_uri",
"(",
"uri",
":",
"Union",
"[",
"URIRef",
",",
"str",
"]",
")",
"->",
"FHIR_RESOURCE",
":",
"uri_str",
"=",
"str",
"(",
"uri",
")",
"m",
"=",
"FHIR_RESOURCE_RE",
".",
"match",
"(",
"uri_str",
")",
"if",
"m",
":",
"retur... | Use the FHIR Regular Expression for Resource URI's to determine the namespace and type
of a given URI. As an example, "http://hl7.org/fhir/Patient/p123" maps to the tuple
``('Patient', 'http://hl7.org/fhir')
:param uri: URI to parse
:return: FHIR_RESOURCE (namespace, type, resource) | [
"Use",
"the",
"FHIR",
"Regular",
"Expression",
"for",
"Resource",
"URI",
"s",
"to",
"determine",
"the",
"namespace",
"and",
"type",
"of",
"a",
"given",
"URI",
".",
"As",
"an",
"example",
"http",
":",
"//",
"hl7",
".",
"org",
"/",
"fhir",
"/",
"Patient"... | train | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/uriutils.py#L42-L60 |
astropy/astropy-helpers | astropy_helpers/distutils_helpers.py | get_dummy_distribution | def get_dummy_distribution():
"""
Returns a distutils Distribution object used to instrument the setup
environment before calling the actual setup() function.
"""
from .setup_helpers import _module_state
if _module_state['registered_commands'] is None:
raise RuntimeError(
'... | python | def get_dummy_distribution():
"""
Returns a distutils Distribution object used to instrument the setup
environment before calling the actual setup() function.
"""
from .setup_helpers import _module_state
if _module_state['registered_commands'] is None:
raise RuntimeError(
'... | [
"def",
"get_dummy_distribution",
"(",
")",
":",
"from",
".",
"setup_helpers",
"import",
"_module_state",
"if",
"_module_state",
"[",
"'registered_commands'",
"]",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'astropy_helpers.setup_helpers.register_commands() must be '"... | Returns a distutils Distribution object used to instrument the setup
environment before calling the actual setup() function. | [
"Returns",
"a",
"distutils",
"Distribution",
"object",
"used",
"to",
"instrument",
"the",
"setup",
"environment",
"before",
"calling",
"the",
"actual",
"setup",
"()",
"function",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/distutils_helpers.py#L23-L53 |
astropy/astropy-helpers | astropy_helpers/distutils_helpers.py | get_distutils_option | def get_distutils_option(option, commands):
""" Returns the value of the given distutils option.
Parameters
----------
option : str
The name of the option
commands : list of str
The list of commands on which this option is available
Returns
-------
val : str or None
... | python | def get_distutils_option(option, commands):
""" Returns the value of the given distutils option.
Parameters
----------
option : str
The name of the option
commands : list of str
The list of commands on which this option is available
Returns
-------
val : str or None
... | [
"def",
"get_distutils_option",
"(",
"option",
",",
"commands",
")",
":",
"dist",
"=",
"get_dummy_distribution",
"(",
")",
"for",
"cmd",
"in",
"commands",
":",
"cmd_opts",
"=",
"dist",
".",
"command_options",
".",
"get",
"(",
"cmd",
")",
"if",
"cmd_opts",
"... | Returns the value of the given distutils option.
Parameters
----------
option : str
The name of the option
commands : list of str
The list of commands on which this option is available
Returns
-------
val : str or None
the value of the given distutils option. If th... | [
"Returns",
"the",
"value",
"of",
"the",
"given",
"distutils",
"option",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/distutils_helpers.py#L62-L87 |
astropy/astropy-helpers | astropy_helpers/distutils_helpers.py | add_command_option | def add_command_option(command, name, doc, is_bool=False):
"""
Add a custom option to a setup command.
Issues a warning if the option already exists on that command.
Parameters
----------
command : str
The name of the command as given on the command line
name : str
The nam... | python | def add_command_option(command, name, doc, is_bool=False):
"""
Add a custom option to a setup command.
Issues a warning if the option already exists on that command.
Parameters
----------
command : str
The name of the command as given on the command line
name : str
The nam... | [
"def",
"add_command_option",
"(",
"command",
",",
"name",
",",
"doc",
",",
"is_bool",
"=",
"False",
")",
":",
"dist",
"=",
"get_dummy_distribution",
"(",
")",
"cmdcls",
"=",
"dist",
".",
"get_command_class",
"(",
"command",
")",
"if",
"(",
"hasattr",
"(",
... | Add a custom option to a setup command.
Issues a warning if the option already exists on that command.
Parameters
----------
command : str
The name of the command as given on the command line
name : str
The name of the build option
doc : str
A short description of the... | [
"Add",
"a",
"custom",
"option",
"to",
"a",
"setup",
"command",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/distutils_helpers.py#L161-L223 |
astropy/astropy-helpers | astropy_helpers/distutils_helpers.py | get_distutils_display_options | def get_distutils_display_options():
""" Returns a set of all the distutils display options in their long and
short forms. These are the setup.py arguments such as --name or --version
which print the project's metadata and then exit.
Returns
-------
opts : set
The long and short form d... | python | def get_distutils_display_options():
""" Returns a set of all the distutils display options in their long and
short forms. These are the setup.py arguments such as --name or --version
which print the project's metadata and then exit.
Returns
-------
opts : set
The long and short form d... | [
"def",
"get_distutils_display_options",
"(",
")",
":",
"short_display_opts",
"=",
"set",
"(",
"'-'",
"+",
"o",
"[",
"1",
"]",
"for",
"o",
"in",
"Distribution",
".",
"display_options",
"if",
"o",
"[",
"1",
"]",
")",
"long_display_opts",
"=",
"set",
"(",
"... | Returns a set of all the distutils display options in their long and
short forms. These are the setup.py arguments such as --name or --version
which print the project's metadata and then exit.
Returns
-------
opts : set
The long and short form display option arguments, including the - or -... | [
"Returns",
"a",
"set",
"of",
"all",
"the",
"distutils",
"display",
"options",
"in",
"their",
"long",
"and",
"short",
"forms",
".",
"These",
"are",
"the",
"setup",
".",
"py",
"arguments",
"such",
"as",
"--",
"name",
"or",
"--",
"version",
"which",
"print"... | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/distutils_helpers.py#L226-L254 |
astropy/astropy-helpers | astropy_helpers/commands/build_sphinx.py | ensure_sphinx_astropy_installed | def ensure_sphinx_astropy_installed():
"""
Make sure that sphinx-astropy is available, installing it temporarily if not.
This returns the available version of sphinx-astropy as well as any
paths that should be added to sys.path for sphinx-astropy to be available.
"""
# We've split out the Sphin... | python | def ensure_sphinx_astropy_installed():
"""
Make sure that sphinx-astropy is available, installing it temporarily if not.
This returns the available version of sphinx-astropy as well as any
paths that should be added to sys.path for sphinx-astropy to be available.
"""
# We've split out the Sphin... | [
"def",
"ensure_sphinx_astropy_installed",
"(",
")",
":",
"# We've split out the Sphinx part of astropy-helpers into sphinx-astropy",
"# but we want it to be auto-installed seamlessly for anyone using",
"# build_docs. We check if it's already installed, and if not, we install",
"# it to a local .eggs... | Make sure that sphinx-astropy is available, installing it temporarily if not.
This returns the available version of sphinx-astropy as well as any
paths that should be added to sys.path for sphinx-astropy to be available. | [
"Make",
"sure",
"that",
"sphinx",
"-",
"astropy",
"is",
"available",
"installing",
"it",
"temporarily",
"if",
"not",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/commands/build_sphinx.py#L40-L89 |
astropy/astropy-helpers | astropy_helpers/utils.py | _get_platlib_dir | def _get_platlib_dir(cmd):
"""
Given a build command, return the name of the appropriate platform-specific
build subdirectory directory (e.g. build/lib.linux-x86_64-2.7)
"""
plat_specifier = '.{0}-{1}'.format(cmd.plat_name, sys.version[0:3])
return os.path.join(cmd.build_base, 'lib' + plat_spec... | python | def _get_platlib_dir(cmd):
"""
Given a build command, return the name of the appropriate platform-specific
build subdirectory directory (e.g. build/lib.linux-x86_64-2.7)
"""
plat_specifier = '.{0}-{1}'.format(cmd.plat_name, sys.version[0:3])
return os.path.join(cmd.build_base, 'lib' + plat_spec... | [
"def",
"_get_platlib_dir",
"(",
"cmd",
")",
":",
"plat_specifier",
"=",
"'.{0}-{1}'",
".",
"format",
"(",
"cmd",
".",
"plat_name",
",",
"sys",
".",
"version",
"[",
"0",
":",
"3",
"]",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"cmd",
".",
... | Given a build command, return the name of the appropriate platform-specific
build subdirectory directory (e.g. build/lib.linux-x86_64-2.7) | [
"Given",
"a",
"build",
"command",
"return",
"the",
"name",
"of",
"the",
"appropriate",
"platform",
"-",
"specific",
"build",
"subdirectory",
"directory",
"(",
"e",
".",
"g",
".",
"build",
"/",
"lib",
".",
"linux",
"-",
"x86_64",
"-",
"2",
".",
"7",
")"... | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/utils.py#L37-L44 |
astropy/astropy-helpers | astropy_helpers/utils.py | get_numpy_include_path | def get_numpy_include_path():
"""
Gets the path to the numpy headers.
"""
# We need to go through this nonsense in case setuptools
# downloaded and installed Numpy for us as part of the build or
# install, since Numpy may still think it's in "setup mode", when
# in fact we're ready to use it... | python | def get_numpy_include_path():
"""
Gets the path to the numpy headers.
"""
# We need to go through this nonsense in case setuptools
# downloaded and installed Numpy for us as part of the build or
# install, since Numpy may still think it's in "setup mode", when
# in fact we're ready to use it... | [
"def",
"get_numpy_include_path",
"(",
")",
":",
"# We need to go through this nonsense in case setuptools",
"# downloaded and installed Numpy for us as part of the build or",
"# install, since Numpy may still think it's in \"setup mode\", when",
"# in fact we're ready to use it to build astropy now.... | Gets the path to the numpy headers. | [
"Gets",
"the",
"path",
"to",
"the",
"numpy",
"headers",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/utils.py#L47-L67 |
astropy/astropy-helpers | astropy_helpers/utils.py | is_path_hidden | def is_path_hidden(filepath):
"""
Determines if a given file or directory is hidden.
Parameters
----------
filepath : str
The path to a file or directory
Returns
-------
hidden : bool
Returns `True` if the file is hidden
"""
name = os.path.basename(os.path.absp... | python | def is_path_hidden(filepath):
"""
Determines if a given file or directory is hidden.
Parameters
----------
filepath : str
The path to a file or directory
Returns
-------
hidden : bool
Returns `True` if the file is hidden
"""
name = os.path.basename(os.path.absp... | [
"def",
"is_path_hidden",
"(",
"filepath",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"filepath",
")",
")",
"if",
"isinstance",
"(",
"name",
",",
"bytes",
")",
":",
"is_dotted",
"=",
"name",... | Determines if a given file or directory is hidden.
Parameters
----------
filepath : str
The path to a file or directory
Returns
-------
hidden : bool
Returns `True` if the file is hidden | [
"Determines",
"if",
"a",
"given",
"file",
"or",
"directory",
"is",
"hidden",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/utils.py#L128-L148 |
astropy/astropy-helpers | astropy_helpers/utils.py | walk_skip_hidden | def walk_skip_hidden(top, onerror=None, followlinks=False):
"""
A wrapper for `os.walk` that skips hidden files and directories.
This function does not have the parameter `topdown` from
`os.walk`: the directories must always be recursed top-down when
using this function.
See also
--------
... | python | def walk_skip_hidden(top, onerror=None, followlinks=False):
"""
A wrapper for `os.walk` that skips hidden files and directories.
This function does not have the parameter `topdown` from
`os.walk`: the directories must always be recursed top-down when
using this function.
See also
--------
... | [
"def",
"walk_skip_hidden",
"(",
"top",
",",
"onerror",
"=",
"None",
",",
"followlinks",
"=",
"False",
")",
":",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"top",
",",
"topdown",
"=",
"True",
",",
"onerror",
"=",
"onerror"... | A wrapper for `os.walk` that skips hidden files and directories.
This function does not have the parameter `topdown` from
`os.walk`: the directories must always be recursed top-down when
using this function.
See also
--------
os.walk : For a description of the parameters | [
"A",
"wrapper",
"for",
"os",
".",
"walk",
"that",
"skips",
"hidden",
"files",
"and",
"directories",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/utils.py#L151-L171 |
astropy/astropy-helpers | astropy_helpers/utils.py | write_if_different | def write_if_different(filename, data):
"""Write `data` to `filename`, if the content of the file is different.
Parameters
----------
filename : str
The file name to be written to.
data : bytes
The data to be written to `filename`.
"""
assert isinstance(data, bytes)
if... | python | def write_if_different(filename, data):
"""Write `data` to `filename`, if the content of the file is different.
Parameters
----------
filename : str
The file name to be written to.
data : bytes
The data to be written to `filename`.
"""
assert isinstance(data, bytes)
if... | [
"def",
"write_if_different",
"(",
"filename",
",",
"data",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"bytes",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"... | Write `data` to `filename`, if the content of the file is different.
Parameters
----------
filename : str
The file name to be written to.
data : bytes
The data to be written to `filename`. | [
"Write",
"data",
"to",
"filename",
"if",
"the",
"content",
"of",
"the",
"file",
"is",
"different",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/utils.py#L174-L195 |
astropy/astropy-helpers | astropy_helpers/utils.py | import_file | def import_file(filename, name=None):
"""
Imports a module from a single file as if it doesn't belong to a
particular package.
The returned module will have the optional ``name`` if given, or else
a name generated from the filename.
"""
# Specifying a traditional dot-separated fully qualifi... | python | def import_file(filename, name=None):
"""
Imports a module from a single file as if it doesn't belong to a
particular package.
The returned module will have the optional ``name`` if given, or else
a name generated from the filename.
"""
# Specifying a traditional dot-separated fully qualifi... | [
"def",
"import_file",
"(",
"filename",
",",
"name",
"=",
"None",
")",
":",
"# Specifying a traditional dot-separated fully qualified name here",
"# results in a number of \"Parent module 'astropy' not found while",
"# handling absolute import\" warnings. Using the same name, the",
"# name... | Imports a module from a single file as if it doesn't belong to a
particular package.
The returned module will have the optional ``name`` if given, or else
a name generated from the filename. | [
"Imports",
"a",
"module",
"from",
"a",
"single",
"file",
"as",
"if",
"it",
"doesn",
"t",
"belong",
"to",
"a",
"particular",
"package",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/utils.py#L198-L229 |
astropy/astropy-helpers | astropy_helpers/utils.py | resolve_name | def resolve_name(name):
"""Resolve a name like ``module.object`` to an object and return it.
Raise `ImportError` if the module or name is not found.
"""
parts = name.split('.')
cursor = len(parts) - 1
module_name = parts[:cursor]
attr_name = parts[-1]
while cursor > 0:
try:
... | python | def resolve_name(name):
"""Resolve a name like ``module.object`` to an object and return it.
Raise `ImportError` if the module or name is not found.
"""
parts = name.split('.')
cursor = len(parts) - 1
module_name = parts[:cursor]
attr_name = parts[-1]
while cursor > 0:
try:
... | [
"def",
"resolve_name",
"(",
"name",
")",
":",
"parts",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"cursor",
"=",
"len",
"(",
"parts",
")",
"-",
"1",
"module_name",
"=",
"parts",
"[",
":",
"cursor",
"]",
"attr_name",
"=",
"parts",
"[",
"-",
"1",
... | Resolve a name like ``module.object`` to an object and return it.
Raise `ImportError` if the module or name is not found. | [
"Resolve",
"a",
"name",
"like",
"module",
".",
"object",
"to",
"an",
"object",
"and",
"return",
"it",
"."
] | train | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/utils.py#L232-L261 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.