[Python-modules-commits] [isodate] 01/01: New upstream release.
Hugo Lefeuvre
hugo6390-guest at moszumanska.debian.org
Sat Jan 17 22:16:18 UTC 2015
This is an automated email from the git hooks/post-receive script.
hugo6390-guest pushed a commit to branch master
in repository isodate.
commit c810439319d1ffabed19c31920b7186ce5954c16
Author: Hugo Lefeuvre <hugo6390 at orange.fr>
Date: Sat Jan 17 23:00:12 2015 +0100
New upstream release.
---
CHANGES.txt | 9 +-
PKG-INFO | 29 +++-
README.rst | 17 +-
debian/changelog | 9 +
debian/control | 2 +-
setup.cfg | 2 +-
setup.py | 11 +-
src/isodate.egg-info/PKG-INFO | 242 --------------------------
src/isodate.egg-info/SOURCES.txt | 26 ---
src/isodate.egg-info/dependency_links.txt | 1 -
src/isodate.egg-info/top_level.txt | 1 -
src/isodate/__init__.py | 23 ++-
src/isodate/duration.py | 56 ++++---
src/isodate/isodates.py | 49 +++---
src/isodate/isodatetime.py | 23 ++-
src/isodate/isoduration.py | 31 ++--
src/isodate/isoerror.py | 5 +-
src/isodate/isostrf.py | 46 ++---
src/isodate/isotime.py | 3 +-
src/isodate/isotzinfo.py | 23 +--
src/isodate/tests/__init__.py | 1 +
src/isodate/tests/test_date.py | 23 +--
src/isodate/tests/test_datetime.py | 20 ++-
src/isodate/tests/test_duration.py | 270 +++++++++++++++---------------
src/isodate/tests/test_pickle.py | 27 ++-
src/isodate/tests/test_strf.py | 17 +-
src/isodate/tests/test_time.py | 24 +--
src/isodate/tzinfo.py | 13 +-
28 files changed, 445 insertions(+), 558 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index ed60495..40ae79c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,10 +2,17 @@
CHANGES
=======
+0.5.1 (2014-11-07)
+------------------
+
+- fixed pickling of Duration objects
+- raise ISO8601Error when there is no 'T' separator in datetime strings (Adrian Coveney)
+
+
0.5.0 (2014-02-23)
------------------
-- ISO8601Error are subclasses of ValueError now
+- ISO8601Error are subclasses of ValueError now (Michael Hrivnak)
- improve compatibility across various python variants and versions
- raise exceptions when using fractional years and months in date
maths with durations
diff --git a/PKG-INFO b/PKG-INFO
index e487953..648e11f 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: isodate
-Version: 0.5.0
+Version: 0.5.1
Summary: An ISO 8601 date/time/duration parser and formater
Home-page: http://cheeseshop.python.org/pypi/isodate
Author: Gerhard Weis
@@ -10,7 +10,22 @@ Description:
ISO 8601 date/time parser
=========================
- .. image:: https://travis-ci.org/gweis/isodate.png?branch=master :target: https://travis-ci.org/gweis/isodate
+ .. image:: https://travis-ci.org/gweis/isodate.png?branch=master
+ :target: https://travis-ci.org/gweis/isodate
+ :alt: Travis-CI
+ .. image:: https://coveralls.io/repos/gweis/isodate/badge.png?branch=master
+ :target: https://coveralls.io/r/gweis/isodate?branch=master
+ :alt: Coveralls
+ .. image:: https://pypip.in/v/isodate/badge.png
+ :target: https://pypi.python.org/pypi/isodate/
+ :alt: Latest Version
+ .. image:: https://pypip.in/d/isodate/badge.png
+ :target: https://pypi.python.org/pypi//isodate/
+ :alt: Downloads
+ .. image:: https://pypip.in/license/isodate/badge.png
+ :target: https://pypi.python.org/pypi/isodate/
+ :alt: License
+
This module implements ISO 8601 date, time and duration parsing.
The implementation follows ISO8601:2004 standard, and implements only
@@ -114,10 +129,17 @@ Description:
CHANGES
=======
+ 0.5.1 (2014-11-07)
+ ------------------
+
+ - fixed pickling of Duration objects
+ - raise ISO8601Error when there is no 'T' separator in datetime strings (Adrian Coveney)
+
+
0.5.0 (2014-02-23)
------------------
- - ISO8601Error are subclasses of ValueError now
+ - ISO8601Error are subclasses of ValueError now (Michael Hrivnak)
- improve compatibility across various python variants and versions
- raise exceptions when using fractional years and months in date
maths with durations
@@ -237,6 +259,7 @@ Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/README.rst b/README.rst
index 81fb196..67a0e51 100644
--- a/README.rst
+++ b/README.rst
@@ -2,7 +2,22 @@
ISO 8601 date/time parser
=========================
-.. image:: https://travis-ci.org/gweis/isodate.png?branch=master :target: https://travis-ci.org/gweis/isodate
+.. image:: https://travis-ci.org/gweis/isodate.png?branch=master
+ :target: https://travis-ci.org/gweis/isodate
+ :alt: Travis-CI
+.. image:: https://coveralls.io/repos/gweis/isodate/badge.png?branch=master
+ :target: https://coveralls.io/r/gweis/isodate?branch=master
+ :alt: Coveralls
+.. image:: https://pypip.in/v/isodate/badge.png
+ :target: https://pypi.python.org/pypi/isodate/
+ :alt: Latest Version
+.. image:: https://pypip.in/d/isodate/badge.png
+ :target: https://pypi.python.org/pypi//isodate/
+ :alt: Downloads
+.. image:: https://pypip.in/license/isodate/badge.png
+ :target: https://pypi.python.org/pypi/isodate/
+ :alt: License
+
This module implements ISO 8601 date, time and duration parsing.
The implementation follows ISO8601:2004 standard, and implements only
diff --git a/debian/changelog b/debian/changelog
index 7c27f86..19a661f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+isodate (0.5.1-1) unstable; urgency=low
+
+ * Team upload.
+ * New upstream release (0.5.1).
+ * debian/control:
+ - Bump Standards-Version to 3.9.6.
+
+ -- Hugo Lefeuvre <hugo6390 at orange.fr> Sat, 17 Jan 2015 22:06:38 +0100
+
isodate (0.5.0-1) unstable; urgency=medium
[ James Hunt ]
diff --git a/debian/control b/debian/control
index d056c32..de98fc6 100644
--- a/debian/control
+++ b/debian/control
@@ -6,7 +6,7 @@ Priority: optional
Build-Depends: debhelper (>= 9),
python-all (>= 2.6.6-3~),
python3-all (>= 3.1.2-6~)
-Standards-Version: 3.9.5
+Standards-Version: 3.9.6
Homepage: https://pypi.python.org/pypi/isodate
Vcs-Git: git://anonscm.debian.org/python-modules/packages/isodate.git
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=python-modules/packages/isodate.git
diff --git a/setup.cfg b/setup.cfg
index 72f9d44..6bc2ff3 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
[egg_info]
-tag_svn_revision = 0
tag_date = 0
tag_build =
+tag_svn_revision = 0
diff --git a/setup.py b/setup.py
index 7080a54..9ab0855 100644
--- a/setup.py
+++ b/setup.py
@@ -46,7 +46,7 @@ def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='isodate',
- version='0.5.0',
+ version='0.5.1',
packages=['isodate', 'isodate.tests'],
package_dir={'': 'src'},
@@ -58,7 +58,7 @@ setup(name='isodate',
author_email='gerhard.weis at proclos.com',
description='An ISO 8601 date/time/duration parser and formater',
license='BSD',
- #keywords = '',
+ # keywords = '',
url='http://cheeseshop.python.org/pypi/isodate',
long_description=(read('README.rst') +
@@ -75,9 +75,10 @@ setup(name='isodate',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Internet',
- 'Topic :: Software Development :: Libraries :: Python Modules',
+ ('Topic :: Software Development :'
+ ': Libraries :: Python Modules'),
],
- **setupargs
- )
+ **setupargs)
diff --git a/src/isodate.egg-info/PKG-INFO b/src/isodate.egg-info/PKG-INFO
deleted file mode 100644
index e487953..0000000
--- a/src/isodate.egg-info/PKG-INFO
+++ /dev/null
@@ -1,242 +0,0 @@
-Metadata-Version: 1.1
-Name: isodate
-Version: 0.5.0
-Summary: An ISO 8601 date/time/duration parser and formater
-Home-page: http://cheeseshop.python.org/pypi/isodate
-Author: Gerhard Weis
-Author-email: gerhard.weis at proclos.com
-License: BSD
-Description:
- ISO 8601 date/time parser
- =========================
-
- .. image:: https://travis-ci.org/gweis/isodate.png?branch=master :target: https://travis-ci.org/gweis/isodate
-
- This module implements ISO 8601 date, time and duration parsing.
- The implementation follows ISO8601:2004 standard, and implements only
- date/time representations mentioned in the standard. If something is not
- mentioned there, then it is treated as non existent, and not as an allowed
- option.
-
- For instance, ISO8601:2004 never mentions 2 digit years. So, it is not
- intended by this module to support 2 digit years. (while it may still
- be valid as ISO date, because it is not explicitly forbidden.)
- Another example is, when no time zone information is given for a time,
- then it should be interpreted as local time, and not UTC.
-
- As this module maps ISO 8601 dates/times to standard Python data types, like
- *date*, *time*, *datetime* and *timedelta*, it is not possible to convert
- all possible ISO 8601 dates/times. For instance, dates before 0001-01-01 are
- not allowed by the Python *date* and *datetime* classes. Additionally
- fractional seconds are limited to microseconds. That means if the parser finds
- for instance nanoseconds it will round it to microseconds.
-
- Documentation
- -------------
-
- Currently there are four parsing methods available.
- * parse_time:
- parses an ISO 8601 time string into a *time* object
- * parse_date:
- parses an ISO 8601 date string into a *date* object
- * parse_datetime:
- parses an ISO 8601 date-time string into a *datetime* object
- * parse_duration:
- parses an ISO 8601 duration string into a *timedelta* or *Duration*
- object.
- * parse_tzinfo:
- parses the time zone info part of an ISO 8601 string into a
- *tzinfo* object.
-
- As ISO 8601 allows to define durations in years and months, and *timedelta*
- does not handle years and months, this module provides a *Duration* class,
- which can be used almost like a *timedelta* object (with some limitations).
- However, a *Duration* object can be converted into a *timedelta* object.
-
- There are also ISO formating methods for all supported data types. Each
- *xxx_isoformat* method accepts a format parameter. The default format is
- always the ISO 8601 expanded format. This is the same format used by
- *datetime.isoformat*:
-
- * time_isoformat:
- Intended to create ISO time strings with default format
- *hh:mm:ssZ*.
- * date_isoformat:
- Intended to create ISO date strings with default format
- *yyyy-mm-dd*.
- * datetime_isoformat:
- Intended to create ISO date-time strings with default format
- *yyyy-mm-ddThh:mm:ssZ*.
- * duration_isoformat:
- Intended to create ISO duration strings with default format
- *PnnYnnMnnDTnnHnnMnnS*.
- * tz_isoformat:
- Intended to create ISO time zone strings with default format
- *hh:mm*.
- * strftime:
- A re-implementation mostly compatible with Python's *strftime*, but
- supports only those format strings, which can also be used for dates
- prior 1900. This method also understands how to format *datetime* and
- *Duration* instances.
-
- Installation:
- -------------
-
- This module can easily be installed with Python standard installation methods.
-
- Either use *python setup.py install* or in case you have *setuptools* or
- *distribute* available, you can also use *easy_install*.
-
- Limitations:
- ------------
-
- * The parser accepts several date/time representation which should be invalid
- according to ISO 8601 standard.
-
- 1. for date and time together, this parser accepts a mixture of basic and extended format.
- e.g. the date could be in basic format, while the time is accepted in extended format.
- It also allows short dates and times in date-time strings.
- 2. For incomplete dates, the first day is chosen. e.g. 19th century results in a date of
- 1901-01-01.
- 3. negative *Duration* and *timedelta* value are not fully supported yet.
-
- Further information:
- --------------------
-
- The doc strings and unit tests should provide rather detailed information about
- the methods and their limitations.
-
- The source release provides a *setup.py* script and a *buildout.cfg*. Both can
- be used to run the unit tests included.
-
- Source code is available at `<http://github.com/gweis/isodate>`_.
-
- CHANGES
- =======
-
- 0.5.0 (2014-02-23)
- ------------------
-
- - ISO8601Error are subclasses of ValueError now
- - improve compatibility across various python variants and versions
- - raise exceptions when using fractional years and months in date
- maths with durations
- - renamed method todatetime on Duraction objects to totimedelta
-
-
- 0.4.9 (2012-10-30)
- ------------------
-
- - support pickling FixedOffset instances
- - make sure parsed fractional seconds are in microseconds
- - add leading zeros when formattig microseconds (Jarom Loveridge)
-
-
- 0.4.8 (2012-05-04)
- ------------------
-
- - fixed incompatibility of unittests with python 2.5 and 2.6 (runs fine on 2.7
- and 3.2)
-
-
- 0.4.7 (2012-01-26)
- ------------------
-
- - fixed tzinfo formatting (never pass None into tzinfo.utcoffset())
-
-
- 0.4.6 (2012-01-06)
- ------------------
-
- - added Python 3 compatibility via 2to3
-
- 0.4.5 (2012-01-06)
- ------------------
-
- - made setuptools dependency optional
-
- 0.4.4 (2011-04-16)
- ------------------
-
- - Fixed formatting of microseconds for datetime objects
-
- 0.4.3 (2010-10-29)
- ------------------
-
- - Fixed problem with %P formating and fractions (supplied by David Brooks)
-
- 0.4.2 (2010-10-28)
- ------------------
-
- - Implemented unary - for Duration (supplied by David Brooks)
- - Output fractional seconds with '%P' format. (partly supplied by David Brooks)
-
- 0.4.1 (2010-10-13)
- ------------------
-
- - fixed bug in comparison between timedelta and Duration.
- - fixed precision problem with microseconds (reported by Tommi Virtanen)
-
- 0.4.0 (2009-02-09)
- ------------------
-
- - added method to parse ISO 8601 time zone strings
- - added methods to create ISO 8601 conforming strings
-
- 0.3.0 (2009-1-05)
- ------------------
-
- - Initial release
-
- TODOs
- =====
-
- This to do list contains some thoughts and ideas about missing features, and
- parts to think about, whether to implement them or not. This list is probably
- not complete.
-
- Missing features:
- -----------------
-
- * time formating does not allow to create fractional representations.
- * parser for ISO intervals.
- * currently microseconds are always padded to a length of 6 characters.
- trailing 0s should be optional
-
- Documentation:
- --------------
-
- * parse_datetime:
- - complete documentation to show what this function allows, but ISO forbids.
- and vice verse.
- - support other separators between date and time than 'T'
-
- * parse_date:
- - yeardigits should be always greater than 4
- - dates before 0001-01-01 are not supported
-
- * parse_duration:
- - alternative formats are not fully supported due to parse_date restrictions
- - standard duration format is fully supported but not very restrictive.
-
- * Duration:
- - support fractional years and month in calculations
- - implement w3c order relation? (`<http://www.w3.org/TR/xmlschema-2/#duration-order>`_)
- - refactor to have duration mathematics only at one place.
- - localize __str__ method (does timedelta do this?)
- - when is a Duration negative?
- - normalize Durations. months [00-12] and years ]-inf,+inf[
-
-Platform: UNKNOWN
-Classifier: Development Status :: 4 - Beta
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: BSD License
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.2
-Classifier: Programming Language :: Python :: 3.3
-Classifier: Programming Language :: Python :: Implementation :: PyPy
-Classifier: Topic :: Internet
-Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/src/isodate.egg-info/SOURCES.txt b/src/isodate.egg-info/SOURCES.txt
deleted file mode 100644
index 37d9c1f..0000000
--- a/src/isodate.egg-info/SOURCES.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-CHANGES.txt
-MANIFEST.in
-README.rst
-TODO.txt
-setup.py
-src/isodate/__init__.py
-src/isodate/duration.py
-src/isodate/isodates.py
-src/isodate/isodatetime.py
-src/isodate/isoduration.py
-src/isodate/isoerror.py
-src/isodate/isostrf.py
-src/isodate/isotime.py
-src/isodate/isotzinfo.py
-src/isodate/tzinfo.py
-src/isodate.egg-info/PKG-INFO
-src/isodate.egg-info/SOURCES.txt
-src/isodate.egg-info/dependency_links.txt
-src/isodate.egg-info/top_level.txt
-src/isodate/tests/__init__.py
-src/isodate/tests/test_date.py
-src/isodate/tests/test_datetime.py
-src/isodate/tests/test_duration.py
-src/isodate/tests/test_pickle.py
-src/isodate/tests/test_strf.py
-src/isodate/tests/test_time.py
\ No newline at end of file
diff --git a/src/isodate.egg-info/dependency_links.txt b/src/isodate.egg-info/dependency_links.txt
deleted file mode 100644
index 8b13789..0000000
--- a/src/isodate.egg-info/dependency_links.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/isodate.egg-info/top_level.txt b/src/isodate.egg-info/top_level.txt
deleted file mode 100644
index 817963d..0000000
--- a/src/isodate.egg-info/top_level.txt
+++ /dev/null
@@ -1 +0,0 @@
-isodate
diff --git a/src/isodate/__init__.py b/src/isodate/__init__.py
index 091af0a..26604c2 100644
--- a/src/isodate/__init__.py
+++ b/src/isodate/__init__.py
@@ -14,11 +14,11 @@
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
@@ -28,12 +28,12 @@
Import all essential functions and constants to re-export them here for easy
access.
-This module contains also various pre-defined ISO 8601 format strings.
+This module contains also various pre-defined ISO 8601 format strings.
'''
from isodate.isodates import parse_date, date_isoformat
from isodate.isotime import parse_time, time_isoformat
from isodate.isodatetime import parse_datetime, datetime_isoformat
-from isodate.isoduration import parse_duration, duration_isoformat, Duration
+from isodate.isoduration import parse_duration, duration_isoformat
from isodate.isoerror import ISO8601Error
from isodate.isotzinfo import parse_tzinfo, tz_isoformat
from isodate.tzinfo import UTC, FixedOffset, LOCAL
@@ -53,3 +53,18 @@ from isodate.isostrf import DT_BAS_ORD_COMPLETE, DT_EXT_ORD_COMPLETE
from isodate.isostrf import DT_BAS_WEEK_COMPLETE, DT_EXT_WEEK_COMPLETE
from isodate.isostrf import D_DEFAULT, D_WEEK, D_ALT_EXT, D_ALT_BAS
from isodate.isostrf import D_ALT_BAS_ORD, D_ALT_EXT_ORD
+
+__all__ = (parse_date, date_isoformat, parse_time, time_isoformat,
+ parse_datetime, datetime_isoformat, parse_duration,
+ duration_isoformat, ISO8601Error, parse_tzinfo,
+ tz_isoformat, UTC, FixedOffset, LOCAL, Duration,
+ strftime, DATE_BAS_COMPLETE, DATE_BAS_ORD_COMPLETE,
+ DATE_BAS_WEEK, DATE_BAS_WEEK_COMPLETE, DATE_CENTURY,
+ DATE_EXT_COMPLETE, DATE_EXT_ORD_COMPLETE, DATE_EXT_WEEK,
+ DATE_EXT_WEEK_COMPLETE, DATE_MONTH, DATE_YEAR,
+ TIME_BAS_COMPLETE, TIME_BAS_MINUTE, TIME_EXT_COMPLETE,
+ TIME_EXT_MINUTE, TIME_HOUR, TZ_BAS, TZ_EXT, TZ_HOUR,
+ DT_BAS_COMPLETE, DT_EXT_COMPLETE, DT_BAS_ORD_COMPLETE,
+ DT_EXT_ORD_COMPLETE, DT_BAS_WEEK_COMPLETE,
+ DT_EXT_WEEK_COMPLETE, D_DEFAULT, D_WEEK, D_ALT_EXT,
+ D_ALT_BAS, D_ALT_BAS_ORD, D_ALT_EXT_ORD)
diff --git a/src/isodate/duration.py b/src/isodate/duration.py
index 4484919..b44faa8 100644
--- a/src/isodate/duration.py
+++ b/src/isodate/duration.py
@@ -40,13 +40,13 @@ def fquotmod(val, low, high):
'''
# assumes that all the maths is done with Decimals.
- # divmod for Decimal uses truncate instead of floor as builtin divmod, so we have
- # to do it manually here.
+ # divmod for Decimal uses truncate instead of floor as builtin
+ # divmod, so we have to do it manually here.
a, b = val - low, high - low
div = (a / b).to_integral(ROUND_FLOOR)
mod = a - div * b
# if we were not usig Decimal, it would look like this.
- #div, mod = divmod(val - low, high - low)
+ # div, mod = divmod(val - low, high - low)
mod += low
return int(div), mod
@@ -101,6 +101,12 @@ class Duration(object):
self.tdelta = timedelta(days, seconds, microseconds, milliseconds,
minutes, hours, weeks)
+ def __getstate__(self):
+ return self.__dict__
+
+ def __setstate__(self, state):
+ self.__dict__.update(state)
+
def __getattr__(self, name):
'''
Provide direct access to attributes of included timedelta instance.
@@ -124,9 +130,9 @@ class Duration(object):
Return a string suitable for repr(x) calls.
'''
return "%s.%s(%d, %d, %d, years=%d, months=%d)" % (
- self.__class__.__module__, self.__class__.__name__,
- self.tdelta.days, self.tdelta.seconds,
- self.tdelta.microseconds, self.years, self.months)
+ self.__class__.__module__, self.__class__.__name__,
+ self.tdelta.days, self.tdelta.seconds,
+ self.tdelta.microseconds, self.years, self.months)
def __neg__(self):
"""
@@ -153,8 +159,10 @@ class Duration(object):
newduration.tdelta = self.tdelta + other.tdelta
return newduration
if isinstance(other, (date, datetime)):
- if (not( float(self.years).is_integer() and float(self.months).is_integer())):
- raise ValueError('fractional years or months not supported for date calculations')
+ if (not(float(self.years).is_integer()
+ and float(self.months).is_integer())):
+ raise ValueError('fractional years or months not supported'
+ ' for date calculations')
newmonth = other.month + self.months
carry, newmonth = fquotmod(newmonth, 1, 13)
newyear = other.year + self.years + carry
@@ -177,8 +185,10 @@ class Duration(object):
newduration.tdelta = self.tdelta + other
return newduration
if isinstance(other, (date, datetime)):
- if (not( float(self.years).is_integer() and float(self.months).is_integer())):
- raise ValueError('fractional years or months not supported for date calculations')
+ if (not(float(self.years).is_integer()
+ and float(self.months).is_integer())):
+ raise ValueError('fractional years or months not supported'
+ ' for date calculations')
newmonth = other.month + self.months
carry, newmonth = fquotmod(newmonth, 1, 13)
newyear = other.year + self.years + carry
@@ -214,10 +224,12 @@ class Duration(object):
It is possible to subtract Duration objecs from date, datetime and
timedelta objects.
'''
- #print '__rsub__:', self, other
+ # print '__rsub__:', self, other
if isinstance(other, (date, datetime)):
- if (not( float(self.years).is_integer() and float(self.months).is_integer())):
- raise ValueError('fractional years or months not supported for date calculations')
+ if (not(float(self.years).is_integer()
+ and float(self.months).is_integer())):
+ raise ValueError('fractional years or months not supported'
+ ' for date calculations')
newmonth = other.month - self.months
carry, newmonth = fquotmod(newmonth, 1, 13)
newyear = other.year - self.years + carry
@@ -240,13 +252,14 @@ class Duration(object):
If the years, month part and the timedelta part are both equal, then
the two Durations are considered equal.
'''
- if (isinstance(other, timedelta) and
- self.years == 0 and self.months == 0):
+ if ((isinstance(other, timedelta) and
+ self.years == 0 and self.months == 0)):
return self.tdelta == other
if not isinstance(other, Duration):
return NotImplemented
- if ((self.years * 12 + self.months) ==
- (other.years * 12 + other.months) and self.tdelta == other.tdelta):
+ if (((self.years * 12 + self.months) ==
+ (other.years * 12 + other.months)
+ and self.tdelta == other.tdelta)):
return True
return False
@@ -255,12 +268,15 @@ class Duration(object):
If the years, month part or the timedelta part is not equal, then
the two Durations are considered not equal.
'''
- if isinstance(other, timedelta) and self.years == 0 and self.months == 0:
+ if ((isinstance(other, timedelta)
+ and self.years == 0
+ and self.months == 0)):
return self.tdelta != other
if not isinstance(other, Duration):
return NotImplemented
- if ((self.years * 12 + self.months) !=
- (other.years * 12 + other.months) or self.tdelta != other.tdelta):
+ if (((self.years * 12 + self.months) !=
+ (other.years * 12 + other.months)
+ or self.tdelta != other.tdelta)):
return True
return False
diff --git a/src/isodate/isodates.py b/src/isodate/isodates.py
index 8bafa20..37d42f8 100644
--- a/src/isodate/isodates.py
+++ b/src/isodate/isodates.py
@@ -14,11 +14,11 @@
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
@@ -42,18 +42,19 @@ DATE_REGEX_CACHE = {}
# A dictionary to cache pre-compiled regular expressions.
# A set of regular expressions is identified, by number of year digits allowed
# and whether a plus/minus sign is required or not. (This option is changeable
-# only for 4 digit years).
+# only for 4 digit years).
+
def build_date_regexps(yeardigits=4, expanded=False):
'''
Compile set of regular expressions to parse ISO dates. The expressions will
be created only if they are not already in REGEX_CACHE.
-
+
It is necessary to fix the number of year digits, else it is not possible
to automatically distinguish between various ISO date formats.
-
+
ISO 8601 allows more than 4 digit years, on prior agreement, but then a +/-
- sign is required (expanded format). To support +/- sign for 4 digit years,
+ sign is required (expanded format). To support +/- sign for 4 digit years,
the expanded parameter needs to be set to True.
'''
if yeardigits != 4:
@@ -73,7 +74,7 @@ def build_date_regexps(yeardigits=4, expanded=False):
% (sign, yeardigits)))
# YYYYMMDD or +- YYYYYYMMDD... basic date format
cache_entry.append(re.compile(r"(?P<sign>[+-]){%d}(?P<year>[0-9]{%d})"
- r"(?P<month>[0-9]{2})(?P<day>[0-9]{2})"
+ r"(?P<month>[0-9]{2})(?P<day>[0-9]{2})"
% (sign, yeardigits)))
# 2. complete week dates:
# YYYY-Www-D or +-YYYYYY-Www-D ... extended week date
@@ -98,7 +99,7 @@ def build_date_regexps(yeardigits=4, expanded=False):
cache_entry.append(re.compile(r"(?P<sign>[+-]){%d}(?P<year>[0-9]{%d})"
r"-W(?P<week>[0-9]{2})"
% (sign, yeardigits)))
- # YYYYWww or +-YYYYYYWww ... basic reduced accuracy week date
+ # YYYYWww or +-YYYYYYWww ... basic reduced accuracy week date
cache_entry.append(re.compile(r"(?P<sign>[+-]){%d}(?P<year>[0-9]{%d})W"
r"(?P<week>[0-9]{2})"
% (sign, yeardigits)))
@@ -120,18 +121,19 @@ def build_date_regexps(yeardigits=4, expanded=False):
DATE_REGEX_CACHE[(yeardigits, expanded)] = cache_entry
return DATE_REGEX_CACHE[(yeardigits, expanded)]
+
def parse_date(datestring, yeardigits=4, expanded=False):
'''
Parse an ISO 8601 date string into a datetime.date object.
-
+
As the datetime.date implementation is limited to dates starting from
0001-01-01, negative dates (BC) and year 0 can not be parsed by this
method.
-
+
For incomplete dates, this method chooses the first day for it. For
- instance if only a century is given, this method returns the 1st of
+ instance if only a century is given, this method returns the 1st of
January in year 1 of this century.
-
+
supported formats: (expanded formats are shown with 6 digits for year)
YYYYMMDD +-YYYYYYMMDD basic complete date
YYYY-MM-DD +-YYYYYY-MM-DD extended complete date
@@ -149,10 +151,10 @@ def parse_date(datestring, yeardigits=4, expanded=False):
@param yeardigits: how many digits are used to represent a year
@param expanded: if True then +/- signs are allowed. This parameter
is forced to True, if yeardigits != 4
-
+
@return: a datetime.date instance represented by datestring
@raise ISO8601Error: if this function can not parse the datestring
- @raise ValueError: if datestring can not be represented by datetime.date
+ @raise ValueError: if datestring can not be represented by datetime.date
'''
if yeardigits != 4:
expanded = True
@@ -163,10 +165,10 @@ def parse_date(datestring, yeardigits=4, expanded=False):
groups = match.groupdict()
# sign, century, year, month, week, day,
# FIXME: negative dates not possible with python standard types
- sign = (groups['sign'] == '-' and -1) or 1
+ sign = (groups['sign'] == '-' and -1) or 1
if 'century' in groups:
return date(sign * (int(groups['century']) * 100 + 1), 1, 1)
- if not 'month' in groups: # weekdate or ordinal date
+ if 'month' not in groups: # weekdate or ordinal date
ret = date(sign * int(groups['year']), 1, 1)
if 'week' in groups:
isotuple = ret.isocalendar()
@@ -175,10 +177,10 @@ def parse_date(datestring, yeardigits=4, expanded=False):
else:
days = 1
# if first week in year, do weeks-1
- return ret + timedelta(weeks=int(groups['week']) -
- (((isotuple[1] == 1) and 1) or 0),
- days = -isotuple[2] + days)
- elif 'day' in groups: # ordinal date
+ return ret + timedelta(weeks=int(groups['week']) -
+ (((isotuple[1] == 1) and 1) or 0),
+ days=-isotuple[2] + days)
+ elif 'day' in groups: # ordinal date
return ret + timedelta(days=int(groups['day'])-1)
else: # year date
return ret
@@ -187,14 +189,15 @@ def parse_date(datestring, yeardigits=4, expanded=False):
day = 1
else:
day = int(groups['day'])
- return date(sign * int(groups['year']),
+ return date(sign * int(groups['year']),
int(groups['month']) or 1, day)
raise ISO8601Error('Unrecognised ISO 8601 date format: %r' % datestring)
+
def date_isoformat(tdate, format=DATE_EXT_COMPLETE, yeardigits=4):
'''
- Format date strings.
-
+ Format date strings.
+
This method is just a wrapper around isodate.isostrf.strftime and uses
Date-Extended-Complete as default format.
'''
diff --git a/src/isodate/isodatetime.py b/src/isodate/isodatetime.py
index 7e4d570..9a5fce0 100644
--- a/src/isodate/isodatetime.py
+++ b/src/isodate/isodatetime.py
@@ -14,11 +14,11 @@
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
@@ -35,26 +35,33 @@ from datetime import datetime
from isodate.isostrf import strftime
from isodate.isostrf import DATE_EXT_COMPLETE, TIME_EXT_COMPLETE, TZ_EXT
from isodate.isodates import parse_date
+from isodate.isoerror import ISO8601Error
from isodate.isotime import parse_time
+
def parse_datetime(datetimestring):
'''
Parses ISO 8601 date-times into datetime.datetime objects.
-
+
This function uses parse_date and parse_time to do the job, so it allows
more combinations of date and time representations, than the actual
ISO 8601:2004 standard allows.
'''
- datestring, timestring = datetimestring.split('T')
+ try:
+ datestring, timestring = datetimestring.split('T')
+ except ValueError:
+ raise ISO8601Error("ISO 8601 time designator 'T' missing. Unable to"
+ " parse datetime string %r" % datetimestring)
tmpdate = parse_date(datestring)
tmptime = parse_time(timestring)
return datetime.combine(tmpdate, tmptime)
-def datetime_isoformat(tdt, format=DATE_EXT_COMPLETE + 'T' +
- TIME_EXT_COMPLETE + TZ_EXT):
+
+def datetime_isoformat(tdt, format=DATE_EXT_COMPLETE + 'T' +
+ TIME_EXT_COMPLETE + TZ_EXT):
'''
- Format datetime strings.
-
+ Format datetime strings.
+
This method is just a wrapper around isodate.isostrf.strftime and uses
Extended-Complete as default format.
'''
diff --git a/src/isodate/isoduration.py b/src/isodate/isoduration.py
index 97affdc..af44661 100644
--- a/src/isodate/isoduration.py
+++ b/src/isodate/isoduration.py
@@ -39,14 +39,15 @@ from isodate.isoerror import ISO8601Error
from isodate.isodatetime import parse_datetime
from isodate.isostrf import strftime, D_DEFAULT
-ISO8601_PERIOD_REGEX = re.compile(r"^(?P<sign>[+-])?"
- r"P(?P<years>[0-9]+([,.][0-9]+)?Y)?"
- r"(?P<months>[0-9]+([,.][0-9]+)?M)?"
- r"(?P<weeks>[0-9]+([,.][0-9]+)?W)?"
- r"(?P<days>[0-9]+([,.][0-9]+)?D)?"
- r"((?P<separator>T)(?P<hours>[0-9]+([,.][0-9]+)?H)?"
- r"(?P<minutes>[0-9]+([,.][0-9]+)?M)?"
- r"(?P<seconds>[0-9]+([,.][0-9]+)?S)?)?$")
+ISO8601_PERIOD_REGEX = re.compile(
+ r"^(?P<sign>[+-])?"
+ r"P(?P<years>[0-9]+([,.][0-9]+)?Y)?"
+ r"(?P<months>[0-9]+([,.][0-9]+)?M)?"
+ r"(?P<weeks>[0-9]+([,.][0-9]+)?W)?"
+ r"(?P<days>[0-9]+([,.][0-9]+)?D)?"
+ r"((?P<separator>T)(?P<hours>[0-9]+([,.][0-9]+)?H)?"
+ r"(?P<minutes>[0-9]+([,.][0-9]+)?M)?"
+ r"(?P<seconds>[0-9]+([,.][0-9]+)?S)?)?$")
# regular expression to parse ISO duartion strings.
@@ -103,11 +104,12 @@ def parse_duration(datestring):
if key not in ('separator', 'sign'):
if val is None:
groups[key] = "0n"
- #print groups[key]
+ # print groups[key]
if key in ('years', 'months'):
groups[key] = Decimal(groups[key][:-1].replace(',', '.'))
else:
- # these values are passed into a timedelta object, which works with floats.
+ # these values are passed into a timedelta object,
+ # which works with floats.
groups[key] = float(groups[key][:-1].replace(',', '.'))
if groups["years"] == 0 and groups["months"] == 0:
ret = timedelta(days=groups["days"], hours=groups["hours"],
@@ -134,10 +136,11 @@ def duration_isoformat(tduration, format=D_DEFAULT):
'''
# TODO: implement better decision for negative Durations.
# should be done in Duration class in consistent way with timedelta.
- if ((isinstance(tduration, Duration) and (tduration.years < 0 or
- tduration.months < 0 or
- tduration.tdelta < timedelta(0)))
- or (isinstance(tduration, timedelta) and (tduration < timedelta(0)))):
+ if (((isinstance(tduration, Duration)
+ and (tduration.years < 0 or tduration.months < 0
+ or tduration.tdelta < timedelta(0)))
+ or (isinstance(tduration, timedelta)
+ and (tduration < timedelta(0))))):
ret = '-'
else:
ret = ''
diff --git a/src/isodate/isoerror.py b/src/isodate/isoerror.py
index edbc5aa..e7b211b 100644
--- a/src/isodate/isoerror.py
+++ b/src/isodate/isoerror.py
@@ -14,11 +14,11 @@
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
@@ -28,5 +28,6 @@
This module defines all exception classes in the whole package.
'''
+
class ISO8601Error(ValueError):
'''Raised when the given ISO string can not be parsed.'''
diff --git a/src/isodate/isostrf.py b/src/isodate/isostrf.py
index 5f3169f..1afc810 100644
--- a/src/isodate/isostrf.py
+++ b/src/isodate/isostrf.py
@@ -69,10 +69,10 @@ DT_EXT_COMPLETE = DATE_EXT_COMPLETE + 'T' + TIME_EXT_COMPLETE + TZ_EXT
DT_BAS_COMPLETE = DATE_BAS_COMPLETE + 'T' + TIME_BAS_COMPLETE + TZ_BAS
DT_EXT_ORD_COMPLETE = DATE_EXT_ORD_COMPLETE + 'T' + TIME_EXT_COMPLETE + TZ_EXT
DT_BAS_ORD_COMPLETE = DATE_BAS_ORD_COMPLETE + 'T' + TIME_BAS_COMPLETE + TZ_BAS
-DT_EXT_WEEK_COMPLETE = DATE_EXT_WEEK_COMPLETE + 'T' + TIME_EXT_COMPLETE +\
- TZ_EXT
-DT_BAS_WEEK_COMPLETE = DATE_BAS_WEEK_COMPLETE + 'T' + TIME_BAS_COMPLETE +\
- TZ_BAS
+DT_EXT_WEEK_COMPLETE = (DATE_EXT_WEEK_COMPLETE + 'T' +
... 887 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/isodate.git
More information about the Python-modules-commits
mailing list