Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jslag/Walker-Art-Center-Collectionspace-data-importer
base: 79a345f245
...
head fork: jslag/Walker-Art-Center-Collectionspace-data-importer
compare: ef7c465a28
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 42 additions and 10 deletions.
  1. +30 −9 wacart/create_cspace_records.py
  2. +12 −1 wacart/create_test.py
View
39 wacart/create_cspace_records.py
@@ -109,9 +109,12 @@ def xml_from(record):
CC = ElementMaker(namespace = "http://collectionspace.org/collectionobject",
nsmap = {'collectionobjects_common':
'http://collectionspace.org/collectionobject'})
- schema = E.schema({'name': 'collectionobjects_common'})
+ WAC = ElementMaker(namespace = "http://walkerart.org/collectionobject",
+ nsmap = {'collectionobjects_wac':
+ 'http://walkerart.org/collectionobject'})
+ cs_schema = E.schema({'name': 'collectionobjects_common'})
if record.has_key('acc_no'):
- schema.append(CC.objectNumber(record['acc_no']))
+ cs_schema.append(CC.objectNumber(record['acc_no']))
if record.has_key('title'):
title_list = CC('titleGroupList')
for title in record['title']:
@@ -121,9 +124,9 @@ def xml_from(record):
CC.titleLanguage('eng')
)
)
- schema.append(title_list)
+ cs_schema.append(title_list)
if record.has_key('date'):
- schema.append(
+ cs_schema.append(
CC.objectProductionDateGroup(
CC.dateDisplayDate(record['date'])
)
@@ -132,7 +135,7 @@ def xml_from(record):
concepts = CC('contentConcepts')
for concept in record['iaia_subject']:
concepts.append(CC.contentConcept(concept))
- schema.append(concepts)
+ cs_schema.append(concepts)
if record.has_key('objectWorkType'):
work_type_list = CC('objectNameList')
@@ -146,21 +149,39 @@ def xml_from(record):
CC.objectNameLanguage('eng')
)
)
+
if record.has_key('description'):
- schema.append(CC.physicalDescription("\n".join(record['description'])))
+ cs_schema.append(CC.physicalDescription("\n".join(record['description'])))
+
if record.has_key('edition') or record.has_key('cast_no'):
values = []
for key in ['edition', 'cast_no']:
if record.has_key(key):
values += record[key]
+ cs_schema.append(CC.editionNumber("\n".join(values)))
- schema.append(CC.editionNumber("\n".join(values)))
if record.has_key('inscription_location'):
- schema.append(CC.inscriptionContent("\n".join(record['inscription_location'])))
+ cs_schema.append(CC.inscriptionContent("\n".join(record['inscription_location'])))
+
+ # There's probably a class of variables that we can easily handle with
+ # just a fieldname mapping; let's set that up, and then let the
+ # exceptions be exceptions
+
+ #
+ # WAC-specific
+ #
+ wac_schema = E.schema({'name': 'collectionobjects_wac'})
+ if record.has_key('condition') or record.has_key('condition_date'):
+ values = []
+ for key in ['condition', 'condition_date']:
+ if record.has_key(key):
+ values += record[key]
+ wac_schema.append(WAC.walkercondition("\n".join(values)))
outer = E.imports(
E('import',
- schema,
+ cs_schema,
+ wac_schema,
{'seq': '1', 'service': 'CollectionObjects', 'type': 'CollectionObject'}
)
)
View
13 wacart/create_test.py
@@ -6,7 +6,7 @@
class TestParsing(unittest.TestCase):
- def testXmlBuild(self):
+ def testBasicXmlBuild(self):
"""should be able to find the object's title and author's birthdate"""
simpleRecord = {'title': ['Unspeakable Test Object Of Blinding Clarity'],
@@ -18,5 +18,16 @@ def testXmlBuild(self):
self.assertTrue(some_xml.find('Clarity') > -1)
self.assertTrue(some_xml.find('2020.142') > -1)
+ def testConditionProcessing(self):
+
+ simpleRecord = {
+ 'acc_no': '2020.142.2',
+ 'condition_date': ['sometime in 1984']
+ }
+ some_xml = create_cspace_records.xml_from(simpleRecord)
+ self.assertTrue(some_xml.find('condition') > -1)
+ self.assertTrue(some_xml.find('1984') > -1)
+ self.assertTrue(some_xml.find('2020.142') > -1)
+
if __name__ == "__main__":
unittest.main()

No commit comments for this range

Something went wrong with that request. Please try again.