Skip to content

Commit 2b02e62

Browse files
committed
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 <[email protected]>
1 parent 896e7f6 commit 2b02e62

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

CONTRIBUTING.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ If you are proposing a feature:
4141

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

4746
Get Started!
4847
------------

hepdata/modules/converter/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from sqlalchemy.orm.exc import NoResultFound
4242
from sqlalchemy import func
4343

44-
import timestring
44+
from dateutil.parser import parse
4545

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

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

hepdata/modules/inspire_api/marcxml_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with HEPData; if not, write to the Free Software Foundation, Inc.,
1818
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19-
import timestring
19+
from dateutil.parser import parse
2020

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

@@ -177,7 +177,7 @@ def get_date(soup):
177177
if datafield.find_all(code=code):
178178
value = datafield.find_all(code=code)[0].string
179179
date = expand_date(value)
180-
return date, timestring.Date(date).year
180+
return date, parse(date).year
181181
return None, None
182182
except IndexError:
183183
return None, None

hepdata/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030

3131
from __future__ import absolute_import, print_function
3232

33-
__version__ = "0.9.4dev20200204"
33+
__version__ = "0.9.4dev20200303"

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pytest-cov
138138
pytest-flask
139139
pytest-mock
140140
pytest-pep8
141-
python-dateutil==2.6.1
141+
python-dateutil==2.8.1
142142
python-editor==1.0.3
143143
pytz==2013b0
144144
PyYAML==4.2b4
@@ -158,7 +158,6 @@ speaklater==1.3
158158
SQLAlchemy==1.3.3
159159
sqlalchemy-mptt==0.2.1
160160
SQLAlchemy-Utils==0.32.19
161-
timestring==1.6.2
162161
twitter==1.15.0
163162
Unidecode==0.4.19
164163
uritools==2.0.0

0 commit comments

Comments
 (0)