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_documentation_string stringlengths 1 47.2k | 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']
... | Populate the ``license`` key. | 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'),
} | Populate the ``540`` MARC field. | 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... | Populate the ``copyright`` key. | 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')... | Populate the ``542`` MARC field. | 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_... | Populate the ``_private_notes`` key.
Also populates the ``_export_to`` key through side effects. | 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'),
... | Populate the ``595`` MARC key.
Also populates the `595_H` MARC key through side effects. | 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 = []
... | Populate the ``595`` MARC field. | 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'),
} | Populate the ``_desy_bookkeeping`` key. | 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... | Populate the ``595_D`` MARC field.
Also populates the ``035`` MARC field through side effects. | 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... | 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. | 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... | Populate the ``experiment`` key.
Also populates the ``legacy_name``, the ``accelerator``, and the
``institutions`` keys through side effects. | 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.... | Populate the ``core`` key.
Also populates the ``deleted`` and ``project_type`` keys through side
effects. | 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 | Populate the ``control_number`` key.
Also populates the ``self`` key through side effects. | 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... | Populate the ``acquisition_source`` key. | 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'))
] | Populate the ``public_notes`` key. | 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'))
] | Populate the ``_private_notes`` key. | 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'))
... | Populate the ``external_system_identifiers`` key.
Also populates the ``new_record`` key through side effects. | 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 | Populate the ``deleted_records`` key. | 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:
... | Populate the ``accelerator_experiments`` key. | 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... | Populate the ``keywords`` key.
Also populates the ``energy_ranges`` key through side effects. | 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 =... | Populate the ``695`` MARC field.
Also populates the ``084`` and ``6531`` MARC fields through side effects. | 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... | Populate the ``collaborations`` key. | 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 = ... | Populate the ``publication_info`` key. | 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... | Populate the ``773`` MARC field.
Also populates the ``7731`` MARC field through side effects. | 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',
... | Populate the ``related_records`` key. | 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',
... | Populate the ``related_records`` key. | 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('... | Populate the ``related_records`` key. | 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... | Populate the ``78708`` MARC field
Also populates the ``78002``, ``78502`` MARC fields through side effects. | 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'))
] | Populate the ``_private_notes`` key. | 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... | Populate the ``proceedings`` key.
Also populates the ``refereed`` key through side effects. | 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... | Populate the ``short_title`` key.
Also populates the ``title_variants`` key through side effects. | 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'))]
... | Populate the ``deleted`` key.
Also populates the ``book_series`` key through side effects. | 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'))] | Populate the ``ranks`` key. | 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... | Create a command line argument parser
Add a few default flags, such as --version
for displaying the program version when invoked | 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
} | Register a new function with a the name `command` and
`description` (which will be shown then help is invoked). | 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:
... | 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 | 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)) | Show help for all available commands or just a single one | 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) | Register a new function for command | 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... | Parse comand line arguments/flags and run program | 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]
... | Create client(s) based on addr | 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) | Call single | 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 | Call multi | 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) | Call remote service(s) | 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() | Close socket(s) | 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.... | Show result or error | 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)
... | Execute local OR remote command and show response | 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... | Parse ctl user input. Double quotes are used
to group together multi words arguments. | 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... | Enter loop, read user input then run command. Repeat | 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... | Reverse namespace lookup. Note that returned namespace may not be unique
:param uri: namespace URI
:return: namespace | 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:
... | Split text into arguments accounting for muti-word arguments
which are double quoted | 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
... | 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 | 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
... | Return an identity signature for file name
:param file_name: name of file
:return: mode, size, last modified time if file exists, otherwise none | 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... | Return an identify signature for url
:param url: item to get signature for
:return: tuple containing last modified, length and, if present, etag | 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 | Return the file or URL signature for name
:param name:
:return: | 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:
... | Read package long description from README file | 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("'") | Read package version | 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() | Remove the prefixes from the graph for aesthetics | 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()] | Add the required prefix definitions
:return: | 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 | Shortcut to rdflib add function
:param subj:
:param pred:
:param obj:
:return: self for chaining | 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... | 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 | 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:
... | Add a fhir:link and RDF type arc if it can be determined
:param subj: reference subject
:param val: reference value | 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... | 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:... | 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... | 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]... | 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... | 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 | 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... | 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... | 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_... | 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 | 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... | 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 | 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) | Return the type of pred
:param pred: predicate to map
:return: | 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 | Raise an exception if 't' is unrecognized
:param t: metadata URI | 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) | Determine whether type "t" is a FHIR primitive type
:param t: type to test
:return: | 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... | 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 | 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... | Determine whether predicate is an 'atomic' type -- i.e it doesn't use a FHIR value representation
:param pred: type to test
:return: | 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)
... | Return the data type for primitive type t, if any
:param t: type
:return: corresponding data type | 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... | 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 | 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... | 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 | 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:
... | 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 | 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... | Clear all cache entries for directory and, if it is a 'pure' directory, remove the directory itself | 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... | 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 ... | 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... | 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... | 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: ... | 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 | 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... | Replace all of the blank nodes in graph gin with FHIR paths
:param gin: input graph
:return: output graph | 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... | 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 | 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] | Dump graph g in a sorted n3 format
:param g: graph to dump
:return: stringified representation of g | 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:
... | 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... | 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,
... | Process infile.
:param infile: input file to be processed
:param outfile: target output file.
:param opts:
:return: | 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
... | 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... | 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"... | Entry point for command line utility | 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... | 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) | 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(
'... | Returns a distutils Distribution object used to instrument the setup
environment before calling the actual setup() function. | 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
... | 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... | 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... | 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... | 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... | 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 -... | 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... | 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. | 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... | Given a build command, return the name of the appropriate platform-specific
build subdirectory directory (e.g. build/lib.linux-x86_64-2.7) | 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... | Gets the path to the numpy headers. | 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... | 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 | 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
--------
... | 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 | 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... | 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`. | 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... | 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. | 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:
... | Resolve a name like ``module.object`` to an object and return it.
Raise `ImportError` if the module or name is not found. | 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.