From a96db69ba715e2840579dd56d897c6a7655a823c Mon Sep 17 00:00:00 2001 From: Eugene Amirov Date: Thu, 18 Jun 2015 00:36:27 +0300 Subject: [PATCH 1/9] Updated travis configuration --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 941033c6d..adf826eda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,10 @@ language: python python: - "2.7" - +env: +- TOXENV=py27 # command to run tests, e.g. python setup.py test -script: python setup.py test +script: tox deploy: provider: pypi From 788d0bb1c50ad1af103805e57bb7ac61052ada18 Mon Sep 17 00:00:00 2001 From: Eugene Amirov Date: Thu, 18 Jun 2015 01:01:54 +0300 Subject: [PATCH 2/9] Installing tox for travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index adf826eda..c7bd9d1f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ python: - "2.7" env: - TOXENV=py27 +install: +- pip install -U tox # command to run tests, e.g. python setup.py test script: tox From baa4bdfe8250b8efed5bc292038f4389a46abe8e Mon Sep 17 00:00:00 2001 From: Eugene Amirov Date: Thu, 18 Jun 2015 01:04:17 +0300 Subject: [PATCH 3/9] Installing wheel for travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c7bd9d1f8..7a4a5fdd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: env: - TOXENV=py27 install: +- pip install -U wheel - pip install -U tox # command to run tests, e.g. python setup.py test script: tox From 9852f4284f9e209c8a42e35a796125173cedc9e6 Mon Sep 17 00:00:00 2001 From: Eugene Amirov Date: Thu, 18 Jun 2015 02:02:49 +0300 Subject: [PATCH 4/9] Updated password for pypi --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7a4a5fdd5..b9cbeb25b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ deploy: distributions: sdist bdist_wheel user: scrapinghub password: - secure: CJWIRI51KvqZrkPf7At1li+bbAZ/pN3iWRUPy0JaKWAC8O8B+GljXQxiXisPyLL1pIikcfLYZScOsKEhE+Uon/beeL1TPimVU3ELr7GYzuIkl3eK7quFUOiJ7glEggA5UyGNmk6goMVgaBQEOwT3gwH2LYwd1uFRvQsgIPY+tks= + secure: "EviWl7/ssRUYyfcQ2G1o+8lc8kLmy0dpLxSDgVerwEmhFWMem+dyfvfGQk7C8C3yDO3J0BrvgbZLj5/UgZRp3lz3imV7b+iQ8ITLYWAU6X8/+XbQ+xcwNfnzxg9Pj1CLXu4CBvT5biSTJ969K2w5lm5l9J/TIqTp9VfypikOgf0=" on: tags: true repo: scrapinghub/dateparser From 4297faf20500159b53e4e50fd3db12b2896cf49e Mon Sep 17 00:00:00 2001 From: Eugene Amirov Date: Thu, 18 Jun 2015 02:29:14 +0300 Subject: [PATCH 5/9] Another attempt on pypi password --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b9cbeb25b..067c29297 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ deploy: distributions: sdist bdist_wheel user: scrapinghub password: - secure: "EviWl7/ssRUYyfcQ2G1o+8lc8kLmy0dpLxSDgVerwEmhFWMem+dyfvfGQk7C8C3yDO3J0BrvgbZLj5/UgZRp3lz3imV7b+iQ8ITLYWAU6X8/+XbQ+xcwNfnzxg9Pj1CLXu4CBvT5biSTJ969K2w5lm5l9J/TIqTp9VfypikOgf0=" + secure: "Vs2Z69YTFzQWVkos7IvP4xk0RAQ35dzVXP+EAmzMkqi9qToTa7jdeF8deY18r3l8093jaJ/ct6NzjNiZ6ryWl1yKBwYoW+jaXjKGVXMFSQdqXiDreu516rqrOiRfZVHy+G9TabjhVrIW2npkxuOP7d0HONOZnNtCn6QrxQwEBzw=" on: tags: true repo: scrapinghub/dateparser From 66ae2f2b8958dd2dd0bdfdc7e5961c72afa52dac Mon Sep 17 00:00:00 2001 From: Eugene Amirov Date: Thu, 18 Jun 2015 03:15:41 +0300 Subject: [PATCH 6/9] Fixed unstable test --- tests/test_date.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/test_date.py b/tests/test_date.py index 7bcb3db50..7fd6c75ad 100644 --- a/tests/test_date.py +++ b/tests/test_date.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import re import unittest from collections import OrderedDict from datetime import datetime, timedelta @@ -473,18 +474,20 @@ def then_parsed_date_has_timezone(self): class TestParserInitialization(BaseTestCase): + UNKNOWN_LANGUAGES_EXCEPTION_RE = re.compile(u"Unknown language\(s\): (.+)") + def setUp(self): super(TestParserInitialization, self).setUp() self.result = NotImplemented @parameterized.expand([ - param(['ur', 'li'], error_message=u"Unknown language(s): u'ur', u'li'"), - param(['ur', 'en'], error_message=u"Unknown language(s): u'ur'"), - param(['pk'], error_message=u"Unknown language(s): u'pk'"), + param(['ur', 'li'], unknown_languages=[u'ur', u'li']), + param(['ur', 'en'], unknown_languages=[u'ur']), + param(['pk'], unknown_languages=[u'pk']), ]) - def test_should_raise_error_when_unknown_language_given(self, shortnames, error_message): + def test_should_raise_error_when_unknown_language_given(self, shortnames, unknown_languages): self.when_parser_is_initialized(languages=shortnames) - self.then_error_was_raised(ValueError, error_message) + self.then_languages_are_unknown(unknown_languages) def when_parser_is_initialized(self, **params): try: @@ -492,6 +495,13 @@ def when_parser_is_initialized(self, **params): except Exception as error: self.error = error + def then_languages_are_unknown(self, unknown_languages): + self.assertIsInstance(self.error, ValueError) + match = self.UNKNOWN_LANGUAGES_EXCEPTION_RE.match(str(self.error)) + self.assertTrue(match) + languages = [shortname[2:-1] for shortname in match.group(1).split(", ")] + self.assertItemsEqual(languages, unknown_languages) + if __name__ == '__main__': unittest.main() From 607b42c955bdecdc1cd0554cada661f48468f8fa Mon Sep 17 00:00:00 2001 From: Eugene Amirov Date: Thu, 18 Jun 2015 12:49:22 +0300 Subject: [PATCH 7/9] Duplicating python version support in README --- README.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index e79b096c1..32d147d5e 100644 --- a/README.rst +++ b/README.rst @@ -99,9 +99,12 @@ Also, it requires PyYAML_ for its language detection module to work. Limitations ----------- -`dateparser` at this point does not support generic parsing of dates with fixed UTC offsets. This restricts its ability to reliably parse time zone aware dates since the use of abbreviated time zones as a sole designator of time zones is not recommended. -Read `Wikipedia Time Zone article`_ for more information. +* Only Python 2 support for now (Python 3 support **will be** added in future versions) + +* `dateparser` at this point does not support generic parsing of dates with fixed UTC offsets. This restricts its ability to reliably parse time zone aware dates since the use of abbreviated time zones as a sole designator of time zones is not recommended. + + Read `Wikipedia Time Zone article`_ for more information. .. _Wikipedia Time Zone Article: https://en.wikipedia.org/wiki/Time_zone#Abbreviations From 25f60c85a84b9d3192700f60820e6cccbf51ca84 Mon Sep 17 00:00:00 2001 From: Eugene Amirov Date: Thu, 18 Jun 2015 13:18:52 +0300 Subject: [PATCH 8/9] Limiting tests to `./tests` folder --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4dc9e8ca5..ef6451af5 100644 --- a/tox.ini +++ b/tox.ini @@ -5,4 +5,4 @@ envlist = py27 deps = -rrequirements.txt -rtests/requirements.txt -commands = nosetests [] +commands = nosetests -v tests [] From ee2ec6ff6310752724dc6b65aeab46fe928dc5f8 Mon Sep 17 00:00:00 2001 From: Eugene Amirov Date: Thu, 18 Jun 2015 16:20:47 +0300 Subject: [PATCH 9/9] Added parse function to history --- HISTORY.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.rst b/HISTORY.rst index 21da1ca00..f674dd115 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,6 +6,7 @@ History 0.2.0 (2015-06-17) ------------------ +* Easy to use `parse` function * Languages definitions using YAML. * Using translation based approach for parsing non-english languages. Previously, :mod:`dateutil.parserinfo` was used for language definitions. * Better period extraction.