Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/converters.py
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | Args: | ||||
- metadata: if the revision is synthetic, this can reference dynamic | - metadata: if the revision is synthetic, this can reference dynamic | ||||
properties. | properties. | ||||
Returns: | Returns: | ||||
Revision dictionary with the same keys as inputs, only: | Revision dictionary with the same keys as inputs, only: | ||||
- sha1s are in hexadecimal strings (id, directory) | - sha1s are in hexadecimal strings (id, directory) | ||||
- bytes are decoded in string (author_name, committer_name, | - bytes are decoded in string (author_name, committer_name, | ||||
author_email, committer_email, message) | author_email, committer_email, message) | ||||
- if message is not utf-8 encoded, message is null and msg_url points | |||||
to the api endpoint to download the revision message as is | |||||
- remaining keys are left as is | - remaining keys are left as is | ||||
""" | """ | ||||
return from_swh(revision, | revision = from_swh(revision, | ||||
hashess=set(['id', 'directory', 'parents', 'children']), | hashess=set(['id', | ||||
'directory', | |||||
'parents', | |||||
'children']), | |||||
bytess=set(['name', | bytess=set(['name', | ||||
'fullname', | 'fullname', | ||||
'email', | 'email']), | ||||
'message']), | |||||
dates={'date', 'committer_date'}) | dates={'date', 'committer_date'}) | ||||
if revision: | |||||
if 'message' in revision: | |||||
try: | |||||
revision['message'] = revision['message'].decode('utf-8') | |||||
except UnicodeDecodeError: | |||||
revision['message'] = None | |||||
revision['msg_url'] = ('/api/1/revision/''%s/raw/' | |||||
olasd: Please use `message_url` instead of `msg_url` for consistency. | |||||
Done Inline ActionsThe converter and the service layer modules are api/view agnostic. It should be the concern of the api layer to test for the message. ardumont: The converter and the service layer modules are api/view agnostic.
To be separated as the… | |||||
% revision['id']) | |||||
return revision | |||||
def from_content(content): | def from_content(content): | ||||
"""Convert swh content to serializable content dictionary. | """Convert swh content to serializable content dictionary. | ||||
""" | """ | ||||
return from_swh(content, | return from_swh(content, | ||||
hashess={'sha1', 'sha1_git', 'sha256'}, | hashess={'sha1', 'sha1_git', 'sha256'}, | ||||
bytess={}, | bytess={}, | ||||
Show All 28 Lines |
Please use message_url instead of msg_url for consistency.