-
Notifications
You must be signed in to change notification settings - Fork 5
Custom Function
Brian Tingle edited this page Oct 26, 2016
·
1 revision
re: https://github.com/ucldc/pynux/#custom-function
one reason for this is to update records in a batch:
# ucm_lija2_funding_note_injection.py
from pprint import pprint as pp
def nuxeo_mapper(docs, nx):
for doc in docs:
descriptions = doc['properties'].get('ucldc_schema:description', None)
if descriptions:
print doc['path']
descriptions.append({
u'item': u'Digitization funded by an Institute for Museum and Library Services (IMLS) Leadership Grant (LG 30-02-0260-02) awarded to the University of California, Merced Library.',
u'type': u'funding',
})
pp(descriptions)
doc['properties'] = { 'ucldc_schema:description': descriptions }
nx.update_nuxeo_properties(doc, uid=doc['uid'])then you can do something like
export PYTHONPATH=.
nxls.py /asset-library/UCX/CollectionZ --show-custom-function ucm_lija2_funding_note_injectionand it will run the clean up function on each document returned.