Changeset View
Changeset View
Standalone View
Standalone View
swh/journal/replay.py
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | if rev.get('metadata') and rev['metadata'].get('extra_headers'): | ||||
if key == 'transplant_source' and isinstance(value, str) | if key == 'transplant_source' and isinstance(value, str) | ||||
else [key, value] | else [key, value] | ||||
for (key, value) in rev['metadata']['extra_headers']] | for (key, value) in rev['metadata']['extra_headers']] | ||||
return rev | return rev | ||||
def _check_date(date): | def _check_date(date): | ||||
"""Returns whether the date can be represented in backends with sane | """Returns whether the date can be represented in backends with sane | ||||
limits on timestamps and timezeones (resp. signed 64-bits and | limits on timestamps and timezones (resp. signed 64-bits and | ||||
signed 16 bits), and that microseconds is valid (ie. between 0 and 10^6). | signed 16 bits), and that microseconds is valid (ie. between 0 and 10^6). | ||||
""" | """ | ||||
if date is None: | |||||
return True | |||||
date = normalize_timestamp(date) | date = normalize_timestamp(date) | ||||
return (-2**63 <= date['timestamp']['seconds'] < 2**63) \ | return (-2**63 <= date['timestamp']['seconds'] < 2**63) \ | ||||
and (0 <= date['timestamp']['microseconds'] < 10**6) \ | and (0 <= date['timestamp']['microseconds'] < 10**6) \ | ||||
and (-2**15 <= date['offset'] < 2**15) | and (-2**15 <= date['offset'] < 2**15) | ||||
def _check_revision_date(rev): | def _check_revision_date(rev): | ||||
"""Exclude revisions with invalid dates. | """Exclude revisions with invalid dates. | ||||
▲ Show 20 Lines • Show All 328 Lines • Show Last 20 Lines |