Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/client/__init__.py
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | def metadata_get(self, metadata_url, log=None): | ||||
msg = 'Problem when retrieving metadata at %s' % metadata_url | msg = 'Problem when retrieving metadata at %s' % metadata_url | ||||
if log: | if log: | ||||
log.error(msg) | log.error(msg) | ||||
raise ValueError(msg) | raise ValueError(msg) | ||||
def status_update(self, update_status_url, status, | def status_update(self, update_status_url, status, | ||||
revision_id=None): | revision_id=None, directory_id=None): | ||||
"""Update the deposit's status. | """Update the deposit's status. | ||||
Args: | Args: | ||||
update_status_url (str): the full deposit's archive | update_status_url (str): the full deposit's archive | ||||
status (str): The status to update the deposit with | status (str): The status to update the deposit with | ||||
revision_id (str/None): the revision's identifier to update to | revision_id (str/None): the revision's identifier to update to | ||||
directory_id (str/None): the directory's identifier to update to | |||||
""" | """ | ||||
payload = {'status': status} | payload = {'status': status} | ||||
if revision_id: | if revision_id: | ||||
payload['revision_id'] = revision_id | payload['revision_id'] = revision_id | ||||
if directory_id: | |||||
payload['directory_id'] = directory_id | |||||
self.do('put', update_status_url, json=payload) | self.do('put', update_status_url, json=payload) | ||||
def check(self, check_url, log=None): | def check(self, check_url, log=None): | ||||
"""Check the deposit's associated data (metadata, archive(s)) | """Check the deposit's associated data (metadata, archive(s)) | ||||
Args: | Args: | ||||
check_url (str): the full deposit's check url | check_url (str): the full deposit's check url | ||||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | def parse_result_ok(self, xml_content): | ||||
vals = tree.xpath( | vals = tree.xpath( | ||||
'/x:entry/x:deposit_swh_id', | '/x:entry/x:deposit_swh_id', | ||||
namespaces={'x': 'http://www.w3.org/2005/Atom'}) | namespaces={'x': 'http://www.w3.org/2005/Atom'}) | ||||
if vals: | if vals: | ||||
deposit_swh_id = vals[0].text | deposit_swh_id = vals[0].text | ||||
else: | else: | ||||
deposit_swh_id = None | deposit_swh_id = None | ||||
vals = tree.xpath( | |||||
'/x:entry/x:deposit_swh_id_context', | |||||
namespaces={'x': 'http://www.w3.org/2005/Atom'}) | |||||
if vals: | |||||
deposit_swh_id_context = vals[0].text | |||||
else: | |||||
deposit_swh_id_context = None | |||||
vals = tree.xpath( | |||||
'/x:entry/x:deposit_swh_anchor_id', | |||||
namespaces={'x': 'http://www.w3.org/2005/Atom'}) | |||||
if vals: | |||||
deposit_swh_anchor_id = vals[0].text | |||||
else: | |||||
deposit_swh_anchor_id = None | |||||
vals = tree.xpath( | |||||
'/x:entry/x:deposit_swh_anchor_id_context', | |||||
namespaces={'x': 'http://www.w3.org/2005/Atom'}) | |||||
if vals: | |||||
deposit_swh_anchor_id_context = vals[0].text | |||||
else: | |||||
deposit_swh_anchor_id_context = None | |||||
ardumont: I disklike that part.
Since the recent changes on the xml parsing, i think we can now merge… | |||||
ardumontAuthorUnsubmitted Not Done Inline Actionsdone in D397 ardumont: done in D397 | |||||
return { | return { | ||||
'deposit_id': deposit_id, | 'deposit_id': deposit_id, | ||||
'deposit_status': deposit_status, | 'deposit_status': deposit_status, | ||||
'deposit_status_detail': deposit_status_detail, | 'deposit_status_detail': deposit_status_detail, | ||||
'deposit_swh_id': deposit_swh_id, | 'deposit_swh_id': deposit_swh_id, | ||||
'deposit_swh_id_context': deposit_swh_id_context, | |||||
'deposit_swh_anchor_id': deposit_swh_anchor_id, | |||||
'deposit_swh_anchor_id_context': deposit_swh_anchor_id_context, | |||||
} | } | ||||
class BaseCreateDepositClient(BaseDepositClient): | class BaseCreateDepositClient(BaseDepositClient): | ||||
"""Deposit client base class to post new deposit. | """Deposit client base class to post new deposit. | ||||
""" | """ | ||||
def __init__(self, config): | def __init__(self, config): | ||||
▲ Show 20 Lines • Show All 232 Lines • Show Last 20 Lines |
I disklike that part.
Since the recent changes on the xml parsing, i think we can now merge the way it's done between server and client part (meaning, we could and should use the same code ;).
As that has nothing to do with the current diff, I will refactor this in another commit (and diff).
That should not be a blocker for that part ;)