示例#1
0
 def get_dwc_args(cls, request):
     """Return dictionary of Darwin Core short names to values."""
     args = dict()
     for arg in request.arguments():
         short_name = concepts.get_short_name(arg)
         if short_name:
             args[short_name] = request.get(arg).strip().lower()
     return args
示例#2
0
def add_dynamic_properties(input_dict, instance, bulkload_state_copy):    
    """Adds dynamic properties from the CSV input_dict to the entity instance."""

    # Ingore deleted records
    if input_dict['recstate'] == 'deleted':
        return datastore.Entity('RecordIndex')
    
    # Populate dynamic properties using Darwin Core short names
    recjson = simplejson.loads(input_dict['recjson'].encode('utf-8'))
    for name,value in recjson.iteritems():
        full_name = concepts.get_full_name(name)
        if not full_name:
            continue
        value = str(value).strip().lower()
        if full_name in DO_NOT_INDEX or not value:
            continue
        instance[concepts.get_short_name(full_name)] = value
    return instance