Last active
October 11, 2019 21:13
-
-
Save markpbaggett/576bc38f6a9939c88c5d89c3ff297844 to your computer and use it in GitHub Desktop.
ArchivesSpace replace double comma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some notes for Kevin:
line 4 says that if a title ends in a comma, do the following: