Exemplo n.º 1
0
    otherwise.
"""

__author__ = "Michael Conlon"
__copyright__ = "Copyright 2015 (c), Michael Conlon"
__license__ = "New BSD License"
__version__ = "0.01"

from vivopump import read_csv_fp, write_csv_fp, get_vivo_types, read_csv
import sys

type_data = read_csv('people_types.txt', delimiter='\t')
type_enum = {type_data[row]['vivo']: type_data[row]['short'] for row in type_data}  # convert spreadsheet to dict
plan_data = read_csv('salary_plan_enum.txt', delimiter='\t')
plan_enum = {plan_data[row]['short']: plan_data[row]['vivo'] for row in plan_data}  # convert spreadsheet to dict
vivo_types = get_vivo_types("?uri a uf:UFEntity . ?uri a foaf:Person .")  # must match entity_sparql
data_in = read_csv_fp(sys.stdin)
data_out = {}
for row, data in data_in.items():
    new_data =dict(data)

    #   Convert the source type to a VIVO type.  The source has an HR code.  Convert that to a VIVO person type URI
    #   using the plan_enum.  Then convert that to the value to be stored in the type data.  Whew.

    src_type = new_data['types']
    if src_type in plan_enum:
        src_type = type_enum[plan_enum[src_type]]

    #   Prepare the types column with values from VIVO, if any

    if new_data['uri'] in vivo_types:
Exemplo n.º 2
0
from vivopump import read_csv_fp, write_csv_fp, get_vivo_types, get_parms, read_csv
import sys

parms = get_parms()
type_data = read_csv('person_types.txt', delimiter='\t')
type_enum = {
    type_data[row]['vivo']: type_data[row]['short']
    for row in type_data
}  # convert spreadsheet to dict
plan_data = read_csv('salary_plan_enum.txt', delimiter='\t')
plan_enum = {
    plan_data[row]['short']: plan_data[row]['vivo']
    for row in plan_data
}  # convert spreadsheet to dict
vivo_types = get_vivo_types("?uri a uf:UFEntity . ?uri a foaf:Person .",
                            parms)  # must match entity_sparql
data_in = read_csv_fp(sys.stdin)
data_out = {}
for row, data in data_in.items():
    new_data = dict(data)

    #   Convert the source type to a VIVO type.  The source has an HR code.  Convert that to a VIVO person type URI
    #   using the plan_enum.  Then convert that to the value to be stored in the type data.  Whew.

    src_type = new_data['types']
    if src_type in plan_enum:
        src_type = type_enum[plan_enum[src_type]]

    #   Prepare the types column with values from VIVO, if any

    if new_data['uri'] in vivo_types:
Exemplo n.º 3
0
 def test_vivo_get_types(self):
     result = get_vivo_types("?uri a foaf:Person .")
     self.assertTrue(len(result) > 0)