Page MenuHomeSoftware Heritage

D3351.id11893.diff
No OneTemporary

D3351.id11893.diff

diff --git a/swh/storage/fixer.py b/swh/storage/fixer.py
--- a/swh/storage/fixer.py
+++ b/swh/storage/fixer.py
@@ -1,5 +1,12 @@
+# Copyright (C) 2020 The Software Heritage developers
+# See the AUTHORS file at the top-level directory of this distribution
+# License: GNU General Public License version 3, or any later version
+# See top-level LICENSE file for more information
+
import copy
+import datetime
import logging
+
from typing import Any, Dict, List, Optional
from swh.model.identifiers import normalize_timestamp
@@ -231,6 +238,19 @@
'status': 'ongoing',
'type': 'hg'}
+ >>> pprint(_fix_origin_visit(
+ ... {'origin': {'type': 'hg', 'url': 'http://foo'},
+ ... 'date': '2020-02-27 14:39:19+00:00',
+ ... 'status': 'ongoing',
+ ... 'snapshot': None,
+ ... }))
+ {'date': datetime.datetime(2020, 2, 27, 14, 39, 19, tzinfo=datetime.timezone.utc),
+ 'metadata': None,
+ 'origin': 'http://foo',
+ 'snapshot': None,
+ 'status': 'ongoing',
+ 'type': 'hg'}
+
Old visit format (origin_visit with no type) raises:
>>> _fix_origin_visit({
@@ -272,6 +292,9 @@
visit["origin"] = visit["origin"]["url"]
if "metadata" not in visit:
visit["metadata"] = None
+ date = visit["date"]
+ if isinstance(date, str):
+ visit["date"] = datetime.datetime.fromisoformat(date)
return visit

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 30, 2:43 PM (7 h, 29 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216910

Event Timeline