Skip to content

Instantly share code, notes, and snippets.

@markpbaggett
Last active October 11, 2019 21:13
Show Gist options
  • Save markpbaggett/576bc38f6a9939c88c5d89c3ff297844 to your computer and use it in GitHub Desktop.
Save markpbaggett/576bc38f6a9939c88c5d89c3ff297844 to your computer and use it in GitHub Desktop.
ArchivesSpace replace double comma
def replace_double_commas_in_archival_object(self, id, repo_id=2):
metadata_from_archival_object = self.get_archival_object(id, repo_id)
title = metadata_from_archival_object['title']
if title.endswith(','):
title = title[:-1]
metadata_from_archival_object['title'] = title
r = requests.post(
url=f'{self.base_url}/repositories/{repo_id}/archival_objects/{id}',
headers=self.headers,
data=json.dumps(metadata_from_archival_object)
)
return r.json()['status']
else:
return {'status': 'Did not update. Title did not end in comma.'}
@markpbaggett
Copy link
Author

Some notes for Kevin:

line 4 says that if a title ends in a comma, do the following:

  • line 5: make title equal title minus the last character
  • line 6: update our metadata from archival object with our new title
  • line 7: update our object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment