[Python-modules-commits] [python-aniso8601] 01/01: Update to upstream version 1.2.0

Jonathan Carter highvoltage-guest at moszumanska.debian.org
Sun Oct 30 07:52:53 UTC 2016


This is an automated email from the git hooks/post-receive script.

highvoltage-guest pushed a commit to branch master
in repository python-aniso8601.

commit d552bbd2bf4075b50024a6a00df173b65398f9b4
Author: Jonathan Carter <jcarter at linux.com>
Date:   Sun Oct 30 09:52:36 2016 +0200

    Update to upstream version 1.2.0
---
 LICENSE                          |   2 +-
 PKG-INFO                         |  28 ++++----
 README.rst                       |  26 +++----
 aniso8601.egg-info/PKG-INFO      |  28 ++++----
 aniso8601.egg-info/SOURCES.txt   |  45 +++++++++++-
 aniso8601.egg-info/requires.txt  |   2 +-
 aniso8601/__init__.py            |   2 +-
 aniso8601/compat.py              |   2 +-
 aniso8601/date.py                |  30 ++++----
 aniso8601/duration.py            | 121 ++++++++++++++++++++++++++++----
 aniso8601/interval.py            |   8 +--
 aniso8601/resolution.py          |   3 +
 aniso8601/tests/test_date.py     |   2 +-
 aniso8601/tests/test_duration.py | 145 ++++++++++++++++++++++++++++++++++++++-
 aniso8601/tests/test_init.py     |   2 +-
 aniso8601/tests/test_interval.py |  56 +++++++++++++--
 aniso8601/tests/test_time.py     |   2 +-
 aniso8601/tests/test_timezone.py |   2 +-
 aniso8601/time.py                |  14 ++--
 aniso8601/timezone.py            |  12 ++--
 debian/changelog                 |  18 +++--
 debian/control                   |  27 ++++----
 debian/copyright                 |   2 +-
 setup.py                         |   2 +-
 24 files changed, 452 insertions(+), 129 deletions(-)

diff --git a/LICENSE b/LICENSE
index 80f217b..d80c5b1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2014, Brandon Nielsen
+Copyright (c) 2016, Brandon Nielsen
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/PKG-INFO b/PKG-INFO
index 8ec7e15..bf0cdb6 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: aniso8601
-Version: 1.1.0
+Version: 1.2.0
 Summary: A library for parsing ISO 8601 strings.
 Home-page: https://bitbucket.org/nielsenb/aniso8601
 Author: Brandon Nielsen
@@ -20,15 +20,15 @@ Description: ===========
         * Python 3 support
         * Logical behavior
         
-         - Parse a time, get a `datetime.time <http://docs.python.org/2/library/datetime.html#datetime.time>`_
-         - Parse a date, get a `datetime.date <http://docs.python.org/2/library/datetime.html#datetime.date>`_
-         - Parse a datetime, get a `datetime.datetime <http://docs.python.org/2/library/datetime.html#datetime.datetime>`_
-         - Parse a duration, get a `datetime.timedelta <http://docs.python.org/2/library/datetime.html#datetime.timedelta>`_
-         - Parse an interval, get a tuple of dates or datetimes
-         - Parse a repeating interval, get a date or datetime `generator <http://www.python.org/dev/peps/pep-0255/>`_
+          - Parse a time, get a `datetime.time <http://docs.python.org/2/library/datetime.html#datetime.time>`_
+          - Parse a date, get a `datetime.date <http://docs.python.org/2/library/datetime.html#datetime.date>`_
+          - Parse a datetime, get a `datetime.datetime <http://docs.python.org/2/library/datetime.html#datetime.datetime>`_
+          - Parse a duration, get a `datetime.timedelta <http://docs.python.org/2/library/datetime.html#datetime.timedelta>`_
+          - Parse an interval, get a tuple of dates or datetimes
+          - Parse a repeating interval, get a date or datetime `generator <http://www.python.org/dev/peps/pep-0255/>`_
         
         * UTC offset represented as fixed-offset tzinfo
-        * `dateutil.relativedelta <http://dateutil.readthedocs.org/en/latest/relativedelta.html>`_ available for calendar accuracy
+        * `dateutil.relativedelta <http://dateutil.readthedocs.io/en/latest/relativedelta.html>`_ available for calendar accuracy
         * No regular expressions
         
         Installation
@@ -171,14 +171,14 @@ Description: ===========
           >>> date(2003,1,31) + two_months
           datetime.date(2003, 3, 31)
         
-        Since it a relative fractional month or year is not logical. A ValueError is raised when attempting to parse a duration with :code:`relative=True` and fractional month or year::
+        Since a relative fractional month or year is not logical, a ValueError is raised when attempting to parse a duration with :code:`relative=True` and fractional month or year::
         
           >>> aniso8601.parse_duration('P2.1Y', relative=True)
           Traceback (most recent call last):
             File "<stdin>", line 1, in <module>
-            File "aniso8601/duration.py", line 29, in parse_duration
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 29, in parse_duration
               return _parse_duration_prescribed(isodurationstr, relative)
-            File "aniso8601/duration.py", line 119, in _parse_duration_prescribed
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 150, in _parse_duration_prescribed
               raise ValueError('Fractional months and years are not defined for relative intervals.')
           ValueError: Fractional months and years are not defined for relative intervals.
         
@@ -262,11 +262,11 @@ Description: ===========
           >>> aniso8601.parse_interval('P1.1Y/2001-02-28', relative=True)
           Traceback (most recent call last):
             File "<stdin>", line 1, in <module>
-            File "aniso8601/interval.py", line 51, in parse_interval
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/interval.py", line 51, in parse_interval
               duration = parse_duration(firstpart, relative=relative)
-            File "aniso8601/duration.py", line 29, in parse_duration
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 29, in parse_duration
               return _parse_duration_prescribed(isodurationstr, relative)
-            File "aniso8601/duration.py", line 119, in _parse_duration_prescribed
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 150, in _parse_duration_prescribed
               raise ValueError('Fractional months and years are not defined for relative intervals.')
           ValueError: Fractional months and years are not defined for relative intervals.
         
diff --git a/README.rst b/README.rst
index 63736fd..623203a 100644
--- a/README.rst
+++ b/README.rst
@@ -12,15 +12,15 @@ Features
 * Python 3 support
 * Logical behavior
 
- - Parse a time, get a `datetime.time <http://docs.python.org/2/library/datetime.html#datetime.time>`_
- - Parse a date, get a `datetime.date <http://docs.python.org/2/library/datetime.html#datetime.date>`_
- - Parse a datetime, get a `datetime.datetime <http://docs.python.org/2/library/datetime.html#datetime.datetime>`_
- - Parse a duration, get a `datetime.timedelta <http://docs.python.org/2/library/datetime.html#datetime.timedelta>`_
- - Parse an interval, get a tuple of dates or datetimes
- - Parse a repeating interval, get a date or datetime `generator <http://www.python.org/dev/peps/pep-0255/>`_
+  - Parse a time, get a `datetime.time <http://docs.python.org/2/library/datetime.html#datetime.time>`_
+  - Parse a date, get a `datetime.date <http://docs.python.org/2/library/datetime.html#datetime.date>`_
+  - Parse a datetime, get a `datetime.datetime <http://docs.python.org/2/library/datetime.html#datetime.datetime>`_
+  - Parse a duration, get a `datetime.timedelta <http://docs.python.org/2/library/datetime.html#datetime.timedelta>`_
+  - Parse an interval, get a tuple of dates or datetimes
+  - Parse a repeating interval, get a date or datetime `generator <http://www.python.org/dev/peps/pep-0255/>`_
 
 * UTC offset represented as fixed-offset tzinfo
-* `dateutil.relativedelta <http://dateutil.readthedocs.org/en/latest/relativedelta.html>`_ available for calendar accuracy
+* `dateutil.relativedelta <http://dateutil.readthedocs.io/en/latest/relativedelta.html>`_ available for calendar accuracy
 * No regular expressions
 
 Installation
@@ -163,14 +163,14 @@ The above treat years as 365 days and months as 30 days. If calendar level accur
   >>> date(2003,1,31) + two_months
   datetime.date(2003, 3, 31)
 
-Since it a relative fractional month or year is not logical. A ValueError is raised when attempting to parse a duration with :code:`relative=True` and fractional month or year::
+Since a relative fractional month or year is not logical, a ValueError is raised when attempting to parse a duration with :code:`relative=True` and fractional month or year::
 
   >>> aniso8601.parse_duration('P2.1Y', relative=True)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
-    File "aniso8601/duration.py", line 29, in parse_duration
+    File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 29, in parse_duration
       return _parse_duration_prescribed(isodurationstr, relative)
-    File "aniso8601/duration.py", line 119, in _parse_duration_prescribed
+    File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 150, in _parse_duration_prescribed
       raise ValueError('Fractional months and years are not defined for relative intervals.')
   ValueError: Fractional months and years are not defined for relative intervals.
 
@@ -254,11 +254,11 @@ Fractional years and months do not make sense for relative intervals. A ValueErr
   >>> aniso8601.parse_interval('P1.1Y/2001-02-28', relative=True)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
-    File "aniso8601/interval.py", line 51, in parse_interval
+    File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/interval.py", line 51, in parse_interval
       duration = parse_duration(firstpart, relative=relative)
-    File "aniso8601/duration.py", line 29, in parse_duration
+    File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 29, in parse_duration
       return _parse_duration_prescribed(isodurationstr, relative)
-    File "aniso8601/duration.py", line 119, in _parse_duration_prescribed
+    File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 150, in _parse_duration_prescribed
       raise ValueError('Fractional months and years are not defined for relative intervals.')
   ValueError: Fractional months and years are not defined for relative intervals.
 
diff --git a/aniso8601.egg-info/PKG-INFO b/aniso8601.egg-info/PKG-INFO
index 8ec7e15..bf0cdb6 100644
--- a/aniso8601.egg-info/PKG-INFO
+++ b/aniso8601.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: aniso8601
-Version: 1.1.0
+Version: 1.2.0
 Summary: A library for parsing ISO 8601 strings.
 Home-page: https://bitbucket.org/nielsenb/aniso8601
 Author: Brandon Nielsen
@@ -20,15 +20,15 @@ Description: ===========
         * Python 3 support
         * Logical behavior
         
-         - Parse a time, get a `datetime.time <http://docs.python.org/2/library/datetime.html#datetime.time>`_
-         - Parse a date, get a `datetime.date <http://docs.python.org/2/library/datetime.html#datetime.date>`_
-         - Parse a datetime, get a `datetime.datetime <http://docs.python.org/2/library/datetime.html#datetime.datetime>`_
-         - Parse a duration, get a `datetime.timedelta <http://docs.python.org/2/library/datetime.html#datetime.timedelta>`_
-         - Parse an interval, get a tuple of dates or datetimes
-         - Parse a repeating interval, get a date or datetime `generator <http://www.python.org/dev/peps/pep-0255/>`_
+          - Parse a time, get a `datetime.time <http://docs.python.org/2/library/datetime.html#datetime.time>`_
+          - Parse a date, get a `datetime.date <http://docs.python.org/2/library/datetime.html#datetime.date>`_
+          - Parse a datetime, get a `datetime.datetime <http://docs.python.org/2/library/datetime.html#datetime.datetime>`_
+          - Parse a duration, get a `datetime.timedelta <http://docs.python.org/2/library/datetime.html#datetime.timedelta>`_
+          - Parse an interval, get a tuple of dates or datetimes
+          - Parse a repeating interval, get a date or datetime `generator <http://www.python.org/dev/peps/pep-0255/>`_
         
         * UTC offset represented as fixed-offset tzinfo
-        * `dateutil.relativedelta <http://dateutil.readthedocs.org/en/latest/relativedelta.html>`_ available for calendar accuracy
+        * `dateutil.relativedelta <http://dateutil.readthedocs.io/en/latest/relativedelta.html>`_ available for calendar accuracy
         * No regular expressions
         
         Installation
@@ -171,14 +171,14 @@ Description: ===========
           >>> date(2003,1,31) + two_months
           datetime.date(2003, 3, 31)
         
-        Since it a relative fractional month or year is not logical. A ValueError is raised when attempting to parse a duration with :code:`relative=True` and fractional month or year::
+        Since a relative fractional month or year is not logical, a ValueError is raised when attempting to parse a duration with :code:`relative=True` and fractional month or year::
         
           >>> aniso8601.parse_duration('P2.1Y', relative=True)
           Traceback (most recent call last):
             File "<stdin>", line 1, in <module>
-            File "aniso8601/duration.py", line 29, in parse_duration
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 29, in parse_duration
               return _parse_duration_prescribed(isodurationstr, relative)
-            File "aniso8601/duration.py", line 119, in _parse_duration_prescribed
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 150, in _parse_duration_prescribed
               raise ValueError('Fractional months and years are not defined for relative intervals.')
           ValueError: Fractional months and years are not defined for relative intervals.
         
@@ -262,11 +262,11 @@ Description: ===========
           >>> aniso8601.parse_interval('P1.1Y/2001-02-28', relative=True)
           Traceback (most recent call last):
             File "<stdin>", line 1, in <module>
-            File "aniso8601/interval.py", line 51, in parse_interval
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/interval.py", line 51, in parse_interval
               duration = parse_duration(firstpart, relative=relative)
-            File "aniso8601/duration.py", line 29, in parse_duration
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 29, in parse_duration
               return _parse_duration_prescribed(isodurationstr, relative)
-            File "aniso8601/duration.py", line 119, in _parse_duration_prescribed
+            File "/home/nielsenb/Jetfuse/aniso8601_working/aniso8601/aniso8601/duration.py", line 150, in _parse_duration_prescribed
               raise ValueError('Fractional months and years are not defined for relative intervals.')
           ValueError: Fractional months and years are not defined for relative intervals.
         
diff --git a/aniso8601.egg-info/SOURCES.txt b/aniso8601.egg-info/SOURCES.txt
index 673304a..ea34aed 100644
--- a/aniso8601.egg-info/SOURCES.txt
+++ b/aniso8601.egg-info/SOURCES.txt
@@ -1,24 +1,65 @@
 LICENSE
 MANIFEST.in
 README.rst
-setup.cfg
 setup.py
 aniso8601/__init__.py
+aniso8601/__init__.pyc
 aniso8601/compat.py
+aniso8601/compat.pyc
 aniso8601/date.py
+aniso8601/date.pyc
 aniso8601/duration.py
+aniso8601/duration.pyc
 aniso8601/interval.py
+aniso8601/interval.pyc
 aniso8601/resolution.py
+aniso8601/resolution.pyc
 aniso8601/time.py
+aniso8601/time.pyc
 aniso8601/timezone.py
+aniso8601/timezone.pyc
 aniso8601.egg-info/PKG-INFO
 aniso8601.egg-info/SOURCES.txt
 aniso8601.egg-info/dependency_links.txt
 aniso8601.egg-info/requires.txt
 aniso8601.egg-info/top_level.txt
+aniso8601/__pycache__/__init__.cpython-34.pyc
+aniso8601/__pycache__/__init__.cpython-35.pyc
+aniso8601/__pycache__/compat.cpython-34.pyc
+aniso8601/__pycache__/compat.cpython-35.pyc
+aniso8601/__pycache__/date.cpython-34.pyc
+aniso8601/__pycache__/date.cpython-35.pyc
+aniso8601/__pycache__/duration.cpython-34.pyc
+aniso8601/__pycache__/duration.cpython-35.pyc
+aniso8601/__pycache__/interval.cpython-34.pyc
+aniso8601/__pycache__/interval.cpython-35.pyc
+aniso8601/__pycache__/resolution.cpython-34.pyc
+aniso8601/__pycache__/resolution.cpython-35.pyc
+aniso8601/__pycache__/time.cpython-34.pyc
+aniso8601/__pycache__/time.cpython-35.pyc
+aniso8601/__pycache__/timezone.cpython-34.pyc
+aniso8601/__pycache__/timezone.cpython-35.pyc
 aniso8601/tests/test_date.py
+aniso8601/tests/test_date.pyc
 aniso8601/tests/test_duration.py
+aniso8601/tests/test_duration.pyc
 aniso8601/tests/test_init.py
+aniso8601/tests/test_init.pyc
 aniso8601/tests/test_interval.py
+aniso8601/tests/test_interval.pyc
 aniso8601/tests/test_time.py
-aniso8601/tests/test_timezone.py
\ No newline at end of file
+aniso8601/tests/test_time.pyc
+aniso8601/tests/test_timezone.py
+aniso8601/tests/test_timezone.pyc
+aniso8601/tests/__pycache__/test_date.cpython-34.pyc
+aniso8601/tests/__pycache__/test_date.cpython-35.pyc
+aniso8601/tests/__pycache__/test_duration.cpython-34.pyc
+aniso8601/tests/__pycache__/test_duration.cpython-35.pyc
+aniso8601/tests/__pycache__/test_init.cpython-34.pyc
+aniso8601/tests/__pycache__/test_init.cpython-35.pyc
+aniso8601/tests/__pycache__/test_interval.cpython-34.pyc
+aniso8601/tests/__pycache__/test_interval.cpython-35.pyc
+aniso8601/tests/__pycache__/test_time.cpython-34.pyc
+aniso8601/tests/__pycache__/test_time.cpython-35.pyc
+aniso8601/tests/__pycache__/test_timezone.cpython-34.pyc
+aniso8601/tests/__pycache__/test_timezone.cpython-35.pyc
\ No newline at end of file
diff --git a/aniso8601.egg-info/requires.txt b/aniso8601.egg-info/requires.txt
index 0f08daa..4ea05ed 100644
--- a/aniso8601.egg-info/requires.txt
+++ b/aniso8601.egg-info/requires.txt
@@ -1 +1 @@
-python-dateutil
+python-dateutil
\ No newline at end of file
diff --git a/aniso8601/__init__.py b/aniso8601/__init__.py
index 9ce6dbf..9f88aef 100644
--- a/aniso8601/__init__.py
+++ b/aniso8601/__init__.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014, Brandon Nielsen
+# Copyright (c) 2016, Brandon Nielsen
 # All rights reserved.
 #
 # This software may be modified and distributed under the terms
diff --git a/aniso8601/compat.py b/aniso8601/compat.py
index 849db51..7c60814 100644
--- a/aniso8601/compat.py
+++ b/aniso8601/compat.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014, Brandon Nielsen
+# Copyright (c) 2016, Brandon Nielsen
 # All rights reserved.
 #
 # This software may be modified and distributed under the terms
diff --git a/aniso8601/date.py b/aniso8601/date.py
index 72805fd..ef2cf96 100644
--- a/aniso8601/date.py
+++ b/aniso8601/date.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014, Brandon Nielsen
+# Copyright (c) 2016, Brandon Nielsen
 # All rights reserved.
 #
 # This software may be modified and distributed under the terms
@@ -24,11 +24,11 @@ def get_date_resolution(isodatestr):
     #YYYY-DDD
     #YYYYDDD
     if isodatestr.startswith('+') or isodatestr.startswith('-'):
-        raise NotImplementedError('ISO8601 extended year representation not supported.')
+        raise NotImplementedError('ISO 8601 extended year representation not supported.')
     isodatestrlen = len(isodatestr)
 
     if isodatestr.find('W') != -1:
-        #Handle ISO8601 week date format
+        #Handle ISO 8601 week date format
         hyphens_present = 1 if isodatestr.find('-') != -1 else 0
         week_date_len = 7 + hyphens_present
         weekday_date_len = 8 + 2*hyphens_present
@@ -41,7 +41,7 @@ def get_date_resolution(isodatestr):
             #YYYYWwwD
             return DateResolution.Weekday
         else:
-            raise ValueError('String is not a valid ISO8601 week date.')
+            raise ValueError('String is not a valid ISO 8601 week date.')
 
     #If the size of the string of 4 or less, assume its a truncated year representation
     if len(isodatestr) <= 4:
@@ -79,10 +79,10 @@ def get_date_resolution(isodatestr):
         return DateResolution.Ordinal
 
     #None of the date representations match
-    raise ValueError('String is not an ISO8601 date, perhaps it represents a time or datetime.')
+    raise ValueError('String is not an ISO 8601 date, perhaps it represents a time or datetime.')
 
 def parse_date(isodatestr):
-    #Given a string in any ISO8601 date format, return a datetime.date
+    #Given a string in any ISO 8601 date format, return a datetime.date
     #object that corresponds to the given date. Valid string formats are:
     #
     #Y[YYY]
@@ -96,7 +96,7 @@ def parse_date(isodatestr):
     #YYYY-DDD
     #YYYYDDD
     #
-    #Note that the ISO8601 date format of ±YYYYY is expressly not supported
+    #Note that the ISO 8601 date format of ±YYYYY is expressly not supported
     return _resolution_map[get_date_resolution(isodatestr)](isodatestr)
 
 def _parse_year(yearstr):
@@ -128,7 +128,7 @@ def _parse_calendar_day(datestr):
         #YYYYMMDD
         strformat = '%Y%m%d'
     else:
-        raise ValueError('String is not a valid ISO8601 calendar day.')
+        raise ValueError('String is not a valid ISO 8601 calendar day.')
 
     parseddatetime = datetime.datetime.strptime(datestr, strformat)
 
@@ -140,7 +140,7 @@ def _parse_calendar_month(datestr):
     datestrlen = len(datestr)
 
     if datestrlen != 7:
-        raise ValueError('String is not a valid ISO8601 calendar month.')
+        raise ValueError('String is not a valid ISO 8601 calendar month.')
 
     parseddatetime = datetime.datetime.strptime(datestr, '%Y-%m')
 
@@ -164,7 +164,7 @@ def _parse_week_day(datestr):
     isoweeknumber = int(datestr[windex + 1:windex + 3])
 
     if isoweeknumber == 0:
-        raise ValueError('00 is not a valid ISO8601 weeknumber.')
+        raise ValueError('00 is not a valid ISO 8601 weeknumber.')
 
     datestrlen = len(datestr)
 
@@ -175,7 +175,7 @@ def _parse_week_day(datestr):
 
             return gregorianyearstart + datetime.timedelta(weeks=isoweeknumber - 1, days=isoday - 1)
         else:
-            raise ValueError('String is not a valid ISO8601 week date.')
+            raise ValueError('String is not a valid ISO 8601 week date.')
     else:
         if datestrlen == 8:
             #YYYYWwwD
@@ -183,7 +183,7 @@ def _parse_week_day(datestr):
 
             return gregorianyearstart + datetime.timedelta(weeks=isoweeknumber - 1, days=isoday - 1)
         else:
-            raise ValueError('String is not a valid ISO8601 week date.')
+            raise ValueError('String is not a valid ISO 8601 week date.')
 
 def _parse_week(datestr):
     #datestr is of the format YYYY-Www, YYYYWww
@@ -199,7 +199,7 @@ def _parse_week(datestr):
     isoweeknumber = int(datestr[windex + 1:windex + 3])
 
     if isoweeknumber == 0:
-        raise ValueError('00 is not a valid ISO8601 weeknumber.')
+        raise ValueError('00 is not a valid ISO 8601 weeknumber.')
 
     datestrlen = len(datestr)
 
@@ -209,13 +209,13 @@ def _parse_week(datestr):
             #Suss out the date
             return gregorianyearstart + datetime.timedelta(weeks=isoweeknumber - 1, days=0)
         else:
-            raise ValueError('String is not a valid ISO8601 week date.')
+            raise ValueError('String is not a valid ISO 8601 week date.')
     else:
         if datestrlen == 7:
             #YYYYWww
             return gregorianyearstart + datetime.timedelta(weeks=isoweeknumber - 1, days=0)
         else:
-            raise ValueError('String is not a valid ISO8601 week date.')
+            raise ValueError('String is not a valid ISO 8601 week date.')
 
 def _parse_ordinal_date(datestr):
     #datestr is of the format YYYY-DDD or YYYYDDD
diff --git a/aniso8601/duration.py b/aniso8601/duration.py
index 041949f..d1a1cea 100644
--- a/aniso8601/duration.py
+++ b/aniso8601/duration.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014, Brandon Nielsen
+# Copyright (c) 2016, Brandon Nielsen
 # All rights reserved.
 #
 # This software may be modified and distributed under the terms
@@ -22,10 +22,10 @@ def parse_duration(isodurationstr, relative=False):
     #P<date>T<time>
 
     if isodurationstr[0] != 'P':
-        raise ValueError('String is not a valid ISO8601 duration.')
+        raise ValueError('ISO 8601 duration must start with a P.')
 
-    #If Y, M, D, H, or S are in the string, assume it is a specified duration
-    if isodurationstr.find('Y') != -1 or isodurationstr.find('M') != -1 or isodurationstr.find('W') != -1 or isodurationstr.find('D') != -1 or isodurationstr.find('H') != -1 or isodurationstr.find('S') != -1:
+    #If Y, M, D, H, S, or W are in the string, assume it is a specified duration
+    if _has_any_component(isodurationstr, ['Y', 'M', 'D', 'H', 'S', 'W']) is True:
         return _parse_duration_prescribed(isodurationstr, relative)
     else:
         return _parse_duration_combined(isodurationstr, relative)
@@ -33,23 +33,41 @@ def parse_duration(isodurationstr, relative=False):
 def _parse_duration_prescribed(durationstr, relative):
     #durationstr can be of the form PnYnMnDTnHnMnS or PnW
 
+    #Make sure the end character is valid
+    #https://bitbucket.org/nielsenb/aniso8601/issues/9/durations-with-trailing-garbage-are-parsed
+    if durationstr[-1] not in ['Y', 'M', 'D', 'H', 'S', 'W']:
+        raise ValueError('ISO 8601 duration must end with a valid character.')
+
     #Make sure only the lowest order element has decimal precision
     if durationstr.count('.') > 1:
-        raise ValueError('String is not a valid ISO8601 duration.')
+        raise ValueError('ISO 8601 allows only lowest order element to have a decimal fraction.')
     elif durationstr.count('.') == 1:
         #There should only ever be 1 letter after a decimal if there is more
         #then one, the string is invalid
         lettercount = 0;
 
         for character in durationstr.split('.')[1]:
-            if character.isalpha() == True:
+            if character.isalpha() is True:
                 lettercount += 1
 
             if lettercount > 1:
-                raise ValueError('String is not a valid ISO8601 duration.')
+                raise ValueError('ISO 8601 duration must end with a single valid character.')
+
+    #Do not allow W in combination with other designators
+    #https://bitbucket.org/nielsenb/aniso8601/issues/2/week-designators-should-not-be-combinable
+    if durationstr.find('W') != -1 and _has_any_component(durationstr, ['Y', 'M', 'D', 'H', 'S']) is True:
+        raise ValueError('ISO 8601 week designators may not be combined with other time designators.')
 
     #Parse the elements of the duration
     if durationstr.find('T') == -1:
+        #Make sure no time portion is included
+        #https://bitbucket.org/nielsenb/aniso8601/issues/7/durations-with-time-components-before-t
+        if _has_any_component(durationstr, ['H', 'S']):
+            raise ValueError('ISO 8601 time components not allowed in duration without prescribed time.')
+
+        if _component_order_correct(durationstr, ['P', 'Y', 'M', 'D', 'W']) is False:
+            raise ValueError('ISO 8601 duration components must be in the correct order.')
+
         if durationstr.find('Y') != -1:
             years = _parse_duration_element(durationstr, 'Y')
         else:
@@ -78,7 +96,22 @@ def _parse_duration_prescribed(durationstr, relative):
         firsthalf = durationstr[:durationstr.find('T')]
         secondhalf = durationstr[durationstr.find('T'):]
 
-        if  firsthalf.find('Y') != -1:
+        #Make sure no time portion is included in the date half
+        #https://bitbucket.org/nielsenb/aniso8601/issues/7/durations-with-time-components-before-t
+        if _has_any_component(firsthalf, ['H', 'S']):
+            raise ValueError('ISO 8601 time components not allowed in date portion of duration.')
+
+        if _component_order_correct(firsthalf, ['P', 'Y', 'M', 'D', 'W']) is False:
+            raise ValueError('ISO 8601 duration components must be in the correct order.')
+
+        #Make sure no date component is included in the time half
+        if _has_any_component(secondhalf, ['Y', 'D']):
+            raise ValueError('ISO 8601 time components not allowed in date portion of duration.')
+
+        if _component_order_correct(secondhalf, ['T', 'H', 'M', 'S']) is False:
+            raise ValueError('ISO 8601 time components in duration must be in the correct order.')
+
+        if firsthalf.find('Y') != -1:
             years = _parse_duration_element(firsthalf, 'Y')
         else:
             years = 0
@@ -88,11 +121,6 @@ def _parse_duration_prescribed(durationstr, relative):
         else:
             months = 0
 
-        if durationstr.find('W') != -1:
-            weeks = _parse_duration_element(durationstr, 'W')
-        else:
-            weeks = 0
-
         if firsthalf.find('D') != -1:
             days = _parse_duration_element(firsthalf, 'D')
         else:
@@ -113,6 +141,9 @@ def _parse_duration_prescribed(durationstr, relative):
         else:
             seconds = 0
 
+        #Weeks can't be included
+        weeks = 0
+
     if relative == True:
         if int(years) != years or int(months) != months:
             #https://github.com/dateutil/dateutil/issues/40
@@ -134,7 +165,7 @@ def _parse_duration_combined(durationstr, relative):
     datevalue = parse_date(datepart)
     timevalue = parse_time(timepart)
 
-    if relative == True:
+    if relative is True:
         return dateutil.relativedelta.relativedelta(years=datevalue.year, months=datevalue.month, days=datevalue.day, hours=timevalue.hour, minutes=timevalue.minute, seconds=timevalue.second, microseconds=timevalue.microsecond)
     else:
         totaldays = datevalue.year * 365 + datevalue.month * 30 + datevalue.day
@@ -155,7 +186,7 @@ def _parse_duration_element(durationstr, elementstr):
     durationendindex = durationstr.find(elementstr)
 
     for characterindex in compat.range(durationendindex - 1, 0, -1):
-        if durationstr[characterindex].isalpha() == True:
+        if durationstr[characterindex].isalpha() is True:
             durationstartindex = characterindex
             break
 
@@ -166,3 +197,63 @@ def _parse_duration_element(durationstr, elementstr):
         durationstr = durationstr.replace(',', '.')
 
     return float(durationstr[durationstartindex:durationendindex])
+
+def _has_any_component(durationstr, components):
+    #Given a duration string, and a list of components, returns True
+    #if any of the listed components are present, False otherwise.
+    #
+    #For instance:
+    #durationstr = 'P1Y'
+    #components = ['Y', 'M']
+    #
+    #returns True
+    #
+    #durationstr = 'P1Y'
+    #components = ['M', 'D']
+    #
+    #returns False
+
+    for component in components:
+        if durationstr.find(component) != -1:
+            return True
+
+    return False
+
+def _component_order_correct(durationstr, componentorder):
+    #Given a duration string, and a list of components, returns
+    #True if the components are in the same order as the
+    #component order list, False otherwise. Characters that
+    #are present in the component order list but not in the
+    #duration string are ignored.
+    #
+    #https://bitbucket.org/nielsenb/aniso8601/issues/8/durations-with-components-in-wrong-order
+    #
+    #durationstr = 'P1Y1M1D'
+    #components = ['P', 'Y', 'M', 'D']
+    #
+    #returns True
+    #
+    #durationstr = 'P1Y1M'
+    #components = ['P', 'Y', 'M', 'D']
+    #
+    #returns True
+    #
+    #durationstr = 'P1D1Y1M'
+    #components = ['P', 'Y', 'M', 'D']
+    #
+    #returns False
+
+    componentindex = 0
+
+    for characterindex in compat.range(len(durationstr)):
+        character = durationstr[characterindex]
+
+        if character in componentorder:
+            #This is a character we need to check the order of
+            if character in componentorder[componentindex:]:
+                componentindex = componentorder.index(character)
+            else:
+                #A character is out of order
+                return False
+
+    return True
diff --git a/aniso8601/interval.py b/aniso8601/interval.py
index d22e73a..b869b09 100644
--- a/aniso8601/interval.py
+++ b/aniso8601/interval.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014, Brandon Nielsen
+# Copyright (c) 2016, Brandon Nielsen
 # All rights reserved.
 #
 # This software may be modified and distributed under the terms
@@ -12,7 +12,7 @@ from aniso8601.time import parse_datetime
 from aniso8601.date import parse_date
 
 def parse_interval(isointervalstr, intervaldelimiter='/', datetimedelimiter='T', relative=False):
-    #Given a string representing an ISO8601 interval, return a
+    #Given a string representing an ISO 8601 interval, return a
     #tuple of datetime.date or date.datetime objects representing the beginning
     #and end of the specified interval. Valid formats are:
     #
@@ -91,7 +91,7 @@ def parse_interval(isointervalstr, intervaldelimiter='/', datetimedelimiter='T',
             return (parse_date(firstpart), parse_date(secondpart))
 
 def parse_repeating_interval(isointervalstr, intervaldelimiter='/', datetimedelimiter='T', relative=False):
-    #Given a string representing an ISO8601 interval repating, return a
+    #Given a string representing an ISO 8601 interval repating, return a
     #generator of datetime.date or date.datetime objects representing the
     #dates specified by the repeating interval. Valid formats are:
     #
@@ -99,7 +99,7 @@ def parse_repeating_interval(isointervalstr, intervaldelimiter='/', datetimedeli
     #R/<interval>
 
     if isointervalstr[0] != 'R':
-        raise ValueError('String is not a valid ISO8601 repeating interval.')
+        raise ValueError('ISO 8601 repeating interval must start with an R.')
 
     #Parse the number of iterations
     iterationpart, intervalpart = isointervalstr.split(intervaldelimiter, 1)
diff --git a/aniso8601/resolution.py b/aniso8601/resolution.py
index 659a39e..ec0685d 100644
--- a/aniso8601/resolution.py
+++ b/aniso8601/resolution.py
@@ -1,5 +1,8 @@
 # -*- coding: utf-8 -*-
 
+# Copyright (c) 2016, Brandon Nielsen
+# All rights reserved.
+#
 # This software may be modified and distributed under the terms
 # of the BSD license.  See the LICENSE file for details.
 
diff --git a/aniso8601/tests/test_date.py b/aniso8601/tests/test_date.py
index 5132333..0e8ec61 100644
--- a/aniso8601/tests/test_date.py
+++ b/aniso8601/tests/test_date.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014, Brandon Nielsen
+# Copyright (c) 2016, Brandon Nielsen
 # All rights reserved.
 #
 # This software may be modified and distributed under the terms
diff --git a/aniso8601/tests/test_duration.py b/aniso8601/tests/test_duration.py
index 8c37778..a80a5c1 100644
--- a/aniso8601/tests/test_duration.py
+++ b/aniso8601/tests/test_duration.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014, Brandon Nielsen
+# Copyright (c) 2016, Brandon Nielsen
 # All rights reserved.
 #
 # This software may be modified and distributed under the terms
@@ -8,10 +8,57 @@
 
 import unittest
 
-from aniso8601.duration import parse_duration, _parse_duration_prescribed, _parse_duration_combined, _parse_duration_element
+from aniso8601.duration import parse_duration, _parse_duration_prescribed, _parse_duration_combined, _parse_duration_element, _has_any_component, _component_order_correct
 
 class TestDurationFunctions(unittest.TestCase):
     def test_parse_duration(self):
+        with self.assertRaises(ValueError):
+            #Duration must start with a P
+            parse_duration('1Y2M3DT4H54M6S')
+
+        with self.assertRaises(ValueError):
+            #Week designator cannot be combined with other time designators
+            #https://bitbucket.org/nielsenb/aniso8601/issues/2/week-designators-should-not-be-combinable
+            parse_duration('P1Y2W')
+
+        #Ensure durations are required to be in the correct order
+        #https://bitbucket.org/nielsenb/aniso8601/issues/7/durations-with-time-components-before-t
+        #https://bitbucket.org/nielsenb/aniso8601/issues/8/durations-with-components-in-wrong-order
+        with self.assertRaises(ValueError):
+            parse_duration('P1S')
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1D1S')
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1H1M')
+
+        with self.assertRaises(ValueError):
+            parse_duration('1Y2M3D1SPT1M')
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1Y2M3D2MT1S')
+
+        with self.assertRaises(ValueError):
+            parse_duration('P2M3D1ST1Y1M')
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1Y2M2MT3D1S')
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1D1Y1M')
+
+        with self.assertRaises(ValueError):
+            parse_duration('PT1S1H')
+
+        #Don't allow garbage after the duration
+        #https://bitbucket.org/nielsenb/aniso8601/issues/9/durations-with-trailing-garbage-are-parsed
+        with self.assertRaises(ValueError):
+            parse_duration('P1Dasdfasdf')
+
+        with self.assertRaises(ValueError):
+            parse_duration('P0003-06-04T12:30:05.5asdfasdf')
+
         resultduration = parse_duration('P1Y2M3DT4H54M6S')
         self.assertEqual(resultduration.days, 428)
         self.assertEqual(resultduration.seconds, 17646)
@@ -122,11 +169,48 @@ class TestDurationFunctions(unittest.TestCase):
 
     def test_parse_duration_prescribed(self):
         with self.assertRaises(ValueError):
+            #Multiple fractions are not allowed
             _parse_duration_prescribed('P1Y2M3DT4H5.1234M6.1234S', False)
 
         with self.assertRaises(ValueError):
+            #Fraction only allowed on final component
             _parse_duration_prescribed('P1Y2M3DT4H5.1234M6S', False)
 
+        #Ensure durations are required to be in the correct order
+        #https://bitbucket.org/nielsenb/aniso8601/issues/7/durations-with-time-components-before-t
+        #https://bitbucket.org/nielsenb/aniso8601/issues/8/durations-with-components-in-wrong-order
+        with self.assertRaises(ValueError):
+            parse_duration('P1S', False)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1D1S', False)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1H1M', False)
+
+        with self.assertRaises(ValueError):
+            parse_duration('1Y2M3D1SPT1M', False)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1Y2M3D2MT1S', False)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P2M3D1ST1Y1M', False)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1Y2M2MT3D1S', False)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1D1Y1M', False)
+
+        with self.assertRaises(ValueError):
+            parse_duration('PT1S1H', False)
+
+        #Don't allow garbage after the duration
+        #https://bitbucket.org/nielsenb/aniso8601/issues/9/durations-with-trailing-garbage-are-parsed
+        with self.assertRaises(ValueError):
+            parse_duration('P1Dasdfasdf', False)
+
         resultduration = _parse_duration_prescribed('P1Y2M3DT4H54M6S', False)
         self.assertEqual(resultduration.days, 428)
         self.assertEqual(resultduration.seconds, 17646)
@@ -209,11 +293,48 @@ class TestDurationFunctions(unittest.TestCase):
 
     def test_parse_duration_prescribed_relative(self):
         with self.assertRaises(ValueError):
+            #Multiple fractions are not allowed
             _parse_duration_prescribed('P1Y2M3DT4H5.1234M6.1234S', True)
 
         with self.assertRaises(ValueError):
+            #Fraction only allowed on final component
             _parse_duration_prescribed('P1Y2M3DT4H5.1234M6S', True)
 
+        #Ensure durations are required to be in the correct order
+        #https://bitbucket.org/nielsenb/aniso8601/issues/7/durations-with-time-components-before-t
+        #https://bitbucket.org/nielsenb/aniso8601/issues/8/durations-with-components-in-wrong-order
+        with self.assertRaises(ValueError):
+            parse_duration('P1S', True)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1D1S', True)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1H1M', True)
+
+        with self.assertRaises(ValueError):
+            parse_duration('1Y2M3D1SPT1M', True)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1Y2M3D2MT1S', True)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P2M3D1ST1Y1M', True)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1Y2M2MT3D1S', True)
+
+        with self.assertRaises(ValueError):
+            parse_duration('P1D1Y1M', True)
+
+        with self.assertRaises(ValueError):
+            parse_duration('PT1S1H', True)
+
+        #Don't allow garbage after the duration
+        #https://bitbucket.org/nielsenb/aniso8601/issues/9/durations-with-trailing-garbage-are-parsed
+        with self.assertRaises(ValueError):
+            parse_duration('P1Dasdfasdf', True)
+
         #Fractional months and years are not defined
         #https://github.com/dateutil/dateutil/issues/40
         with self.assertRaises(ValueError):
@@ -237,6 +358,11 @@ class TestDurationFunctions(unittest.TestCase):
         self.assertEqual(resultduration.days, 10.5) #Fractional weeks are allowed
 
     def test_parse_duration_combined(self):
+        #Don't allow garbage after the duration
+        #https://bitbucket.org/nielsenb/aniso8601/issues/9/durations-with-trailing-garbage-are-parsed
+        with self.assertRaises(ValueError):
+            parse_duration('P0003-06-04T12:30:05.5asdfasdf', True)
+
         resultduration = _parse_duration_combined('P0003-06-04T12:30:05', False)
         self.assertEqual(resultduration.days, 1279)
         self.assertEqual(resultduration.seconds, 45005)
@@ -248,6 +374,11 @@ class TestDurationFunctions(unittest.TestCase):
         self.assertEqual(resultduration.microseconds, 500000)
 
     def test_parse_duration_combined_relative(self):
+        #Don't allow garbage after the duration
+        #https://bitbucket.org/nielsenb/aniso8601/issues/9/durations-with-trailing-garbage-are-parsed
+        with self.assertRaises(ValueError):
+            parse_duration('P0003-06-04T12:30:05.5asdfasdf', True)
+
         resultduration = _parse_duration_combined('P0003-06-04T12:30:05', True)
         self.assertEqual(resultduration.years, 3)
         self.assertEqual(resultduration.months, 6)
@@ -275,3 +406,13 @@ class TestDurationFunctions(unittest.TestCase):
         self.assertEqual(_parse_duration_element('PT4H54M6,5S', 'H'), 4)
         self.assertEqual(_parse_duration_element('PT4H54M6,5S', 'M'), 54)
         self.assertEqual(_parse_duration_element('PT4H54M6,5S', 'S'), 6.5)
+
+    def test_has_any_component(self):
+        self.assertTrue(_has_any_component('P1Y', ['Y', 'M']))
+        self.assertFalse(_has_any_component('P1Y', ['M', 'D']))
+
+    def test_component_order_correct(self):
+        self.assertTrue(_component_order_correct('P1Y1M1D', ['P', 'Y', 'M', 'D']))
+        self.assertTrue(_component_order_correct('P1Y1M', ['P', 'Y', 'M', 'D']))
+        self.assertFalse(_component_order_correct('P1D1Y1M', ['P', 'Y', 'M', 'D']))
+        self.assertFalse(_component_order_correct('PT1S1H', ['T', 'H', 'M', 'S']))
diff --git a/aniso8601/tests/test_init.py b/aniso8601/tests/test_init.py
index 0ba0b0b..5736695 100644
--- a/aniso8601/tests/test_init.py
+++ b/aniso8601/tests/test_init.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014, Brandon Nielsen
+# Copyright (c) 2016, Brandon Nielsen
 # All rights reserved.
 #
 # This software may be modified and distributed under the terms
diff --git a/aniso8601/tests/test_interval.py b/aniso8601/tests/test_interval.py
index aced034..a4eb555 100644
--- a/aniso8601/tests/test_interval.py
+++ b/aniso8601/tests/test_interval.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014, Brandon Nielsen
+# Copyright (c) 2016, Brandon Nielsen
 # All rights reserved.
 #
 # This software may be modified and distributed under the terms
@@ -9,10 +9,25 @@
 import unittest
 import datetime
 
+from aniso8601 import compat
 from aniso8601.interval import parse_interval, parse_repeating_interval
 
 class TestIntervalFunctions(unittest.TestCase):
     def test_parse_interval(self):
+        #Don't allow garbage after the duration
+        #https://bitbucket.org/nielsenb/aniso8601/issues/9/durations-with-trailing-garbage-are-parsed
+        with self.assertRaises(ValueError):
+            parse_interval('2001/P1Dasdf')
+
+        with self.assertRaises(ValueError):
+            parse_interval('P1Dasdf/2001')
+
+        with self.assertRaises(ValueError):
+            parse_interval('2001/P0003-06-04T12:30:05.5asdfasdf')
+
+        with self.assertRaises(ValueError):
+            parse_interval('P0003-06-04T12:30:05.5asdfasdf/2001')
+
         resultinterval = parse_interval('P1M/1981-04-05T01:01:00')
         self.assertEqual(resultinterval[0], datetime.datetime(year=1981, month=4, day=5, hour=1, minute=1))
         self.assertEqual(resultinterval[1], datetime.datetime(year=1981, month=3, day=6, hour=1, minute=1))
@@ -74,6 +89,21 @@ class TestIntervalFunctions(unittest.TestCase):
         self.assertEqual(resultinterval[1], datetime.datetime(year=1981, month=4, day=5, hour=1, minute=1))
 
     def test_parse_interval_relative(self):
+        #Don't allow garbage after the duration
+        #https://bitbucket.org/nielsenb/aniso8601/issues/9/durations-with-trailing-garbage-are-parsed
+        with self.assertRaises(ValueError):
+            parse_interval('2001/P1Dasdf', relative=True)
+
... 315 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-aniso8601.git



More information about the Python-modules-commits mailing list