Skip to content
Permalink
Browse files
converter/inspire_api: replace timestring.Date by dateutil.parser.parse
* dateutil.parser.parse already used elsewhere in the code.
* Fixes #181 ("timestring: work around 29th February bug").

Signed-off-by: Graeme Watt <graeme.watt@durham.ac.uk>
  • Loading branch information
GraemeWatt committed Mar 3, 2020
1 parent 896e7f6 commit 2b02e62bcfc1e9f88121f625d25b6c4e646f98f8
Showing 5 changed files with 9 additions and 11 deletions.
@@ -41,8 +41,7 @@ If you are proposing a feature:

* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)
* Remember that contributions are welcome :)

Get Started!
------------
@@ -41,7 +41,7 @@
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy import func

import timestring
from dateutil.parser import parse

logging.basicConfig()
log = logging.getLogger(__name__)
@@ -278,7 +278,7 @@ def download_submission(submission, file_format, offline=False, force=False, riv
# Otherwise guess the Rivet analysis name using the collaboration name,
# the creation year of the INSPIRE record, and the INSPIRE ID.
if 'rivet_analysis_name' not in converter_options:
year = timestring.Date(record['creation_date']).year
year = parse(record['creation_date']).year
converter_options['rivet_analysis_name'] = '{0}_{1}_I{2}'.format(
''.join(record['collaborations']).upper(), year, submission.inspire_id)

@@ -511,7 +511,7 @@ def download_datatable(datasubmission, file_format, *args, **kwargs):
# Otherwise guess the Rivet analysis name using the collaboration name,
# the creation year of the INSPIRE record, and the INSPIRE ID.
if 'rivet_analysis_name' not in options:
year = timestring.Date(record['creation_date']).year
year = parse(record['creation_date']).year
options['rivet_analysis_name'] = '{0}_{1}_I{2}'.format(
''.join(record['collaborations']).upper(), year, datasubmission.publication_inspire_id)

@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with HEPData; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
import timestring
from dateutil.parser import parse

marc_tags = {
'title': ('245', 'a'),
@@ -64,7 +64,7 @@ def get_year(soup):
try:
tag, code = marc_tags['year']
datafield = soup.find_all(tag=tag)[0]
return timestring.Date(datafield.find_all(code=code)[0].string).year
return parse(datafield.find_all(code=code)[0].string).year
except:
return None

@@ -177,7 +177,7 @@ def get_date(soup):
if datafield.find_all(code=code):
value = datafield.find_all(code=code)[0].string
date = expand_date(value)
return date, timestring.Date(date).year
return date, parse(date).year
return None, None
except IndexError:
return None, None
@@ -30,4 +30,4 @@

from __future__ import absolute_import, print_function

__version__ = "0.9.4dev20200204"
__version__ = "0.9.4dev20200303"
@@ -138,7 +138,7 @@ pytest-cov
pytest-flask
pytest-mock
pytest-pep8
python-dateutil==2.6.1
python-dateutil==2.8.1
python-editor==1.0.3
pytz==2013b0
PyYAML==4.2b4
@@ -158,7 +158,6 @@ speaklater==1.3
SQLAlchemy==1.3.3
sqlalchemy-mptt==0.2.1
SQLAlchemy-Utils==0.32.19
timestring==1.6.2
twitter==1.15.0
Unidecode==0.4.19
uritools==2.0.0

0 comments on commit 2b02e62

Please sign in to comment.