diff --git a/swh/storage/api/client.py b/swh/storage/api/client.py --- a/swh/storage/api/client.py +++ b/swh/storage/api/client.py @@ -162,16 +162,7 @@ def origin_add_one(self, origin): return self.post('origin/add', {'origin': origin}) - def origin_visit_add(self, origin, date, type=None, *, ts=None): - if ts is None: - if date is None: - raise TypeError('origin_visit_add expected 2 arguments.') - else: - assert date is None - warnings.warn("argument 'ts' of origin_visit_add was renamed " - "to 'date' in v0.0.109.", - DeprecationWarning) - date = ts + def origin_visit_add(self, origin, date, type=None): return self.post( 'origin/visit/add', {'origin': origin, 'date': date, 'type': type}) diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py --- a/swh/storage/in_memory.py +++ b/swh/storage/in_memory.py @@ -13,7 +13,6 @@ import datetime import itertools import random -import warnings import attr @@ -1221,7 +1220,7 @@ raise NotImplementedError('fetch_history_get is deprecated, use ' 'origin_visit_get instead.') - def origin_visit_add(self, origin, date=None, type=None, *, ts=None): + def origin_visit_add(self, origin, date, type=None): """Add an origin_visit for the origin at date with status 'ongoing'. For backward compatibility, `type` is optional and defaults to @@ -1229,7 +1228,7 @@ Args: origin (Union[int,str]): visited origin's identifier or URL - date: timestamp of such visit + date (Union[str,datetime]): timestamp of such visit type (str): the type of loader used for the visit (hg, git, ...) Returns: @@ -1239,21 +1238,12 @@ - visit: the visit's identifier for the new visit occurrence """ - if ts is None: - if date is None: - raise TypeError('origin_visit_add expected 2 arguments.') - else: - assert date is None - warnings.warn("argument 'ts' of origin_visit_add was renamed " - "to 'date' in v0.0.109.", - DeprecationWarning) - date = ts - origin_url = self._get_origin_url(origin) if origin_url is None: raise ValueError('Unknown origin.') if isinstance(date, str): + # FIXME: Converge on iso8601 at some point date = dateutil.parser.parse(date) elif not isinstance(date, datetime.datetime): raise TypeError('date must be a datetime or a string.') diff --git a/swh/storage/storage.py b/swh/storage/storage.py --- a/swh/storage/storage.py +++ b/swh/storage/storage.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2018 The Software Heritage developers +# Copyright (C) 2015-2019 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 @@ -10,7 +10,6 @@ import datetime import itertools import json -import warnings import dateutil.parser import psycopg2 @@ -1172,8 +1171,8 @@ return None @db_transaction() - def origin_visit_add(self, origin, date=None, type=None, - db=None, cur=None, *, ts=None): + def origin_visit_add(self, origin, date, type=None, + db=None, cur=None): """Add an origin_visit for the origin at ts with status 'ongoing'. For backward compatibility, `type` is optional and defaults to @@ -1181,7 +1180,7 @@ Args: origin (Union[int,str]): visited origin's identifier or URL - date: timestamp of such visit + date (Union[str,datetime]): timestamp of such visit type (str): the type of loader used for the visit (hg, git, ...) Returns: @@ -1191,16 +1190,6 @@ - visit: the visit identifier for the new visit occurrence """ - if ts is None: - if date is None: - raise TypeError('origin_visit_add expected 2 arguments.') - else: - assert date is None - warnings.warn("argument 'ts' of origin_visit_add was renamed " - "to 'date' in v0.0.109.", - DeprecationWarning) - date = ts - if isinstance(origin, str): origin = self.origin_get({'url': origin}, db=db, cur=cur) origin_id = origin['id'] @@ -1209,6 +1198,7 @@ origin_id = origin['id'] if isinstance(date, str): + # FIXME: Converge on iso8601 at some point date = dateutil.parser.parse(date) if type is None: