Skip to content

Commit dcec9ba

Browse files
committed
Never mind, use isodate since it isn't broken.
1 parent 697c9d1 commit dcec9ba

File tree

3 files changed

+10
-40
lines changed

3 files changed

+10
-40
lines changed

docs/validate.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The Basics
1212
The simplest way to validate an instance under a given schema is to use the
1313
:func:`validate` function.
1414

15-
.. autofunction:: validate
15+
.. function:: validate
1616

1717

1818
The Validator Interface
@@ -339,16 +339,14 @@ On OSes with the ``socket.inet_pton`` function, an additional checker for
339339
False
340340

341341

342-
If the iso8601_ library is present, a date-time checker will also be present.
342+
If the isodate_ library is present, a date-time checker will also be present.
343343

344344
.. function:: is_date_time
345345

346346
Check if the instance is in ISO 8601 ``YYYY-MM-DDThh:mm:ssZ`` format.
347347

348348
>>> is_date_time("1970-01-01T00:00:00.0Z")
349349
True
350-
>>> is_date_time("1970-01-01 00:00:00 GMT")
351-
False
352350
>>> is_date_time("0000-58-59T60:61:62")
353351
False
354352

@@ -378,5 +376,5 @@ CSS will be enabled:
378376
>>> is_css_color_code("#CC8899")
379377
True
380378

381-
.. _iso8601: http://pypi.python.org/pypi/iso8601/
379+
.. _isodate: http://pypi.python.org/pypi/isodate/
382380
.. _webcolors: http://pypi.python.org/pypi/webcolors/

jsonschema.py

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
webcolors = None
2828

2929
try:
30-
import iso8601
30+
import isodate
3131
except ImportError:
32-
iso8601 = None
32+
isodate = None
3333

3434

3535
__version__ = "1.0.0-dev"
@@ -641,13 +641,13 @@ def is_regex(instance):
641641
return False
642642

643643

644-
if iso8601 is not None:
644+
if isodate is not None:
645645
@FormatChecker.cls_checks("date-time")
646646
def is_date_time(instance):
647647
try:
648-
iso8601.parse_date(instance)
648+
isodate.parse_datetime(instance)
649649
return True
650-
except ValueError:
650+
except (ValueError, isodate.ISO8601Error):
651651
return False
652652

653653

@@ -967,32 +967,5 @@ def _uniq(container):
967967

968968

969969
def validate(instance, schema, cls=Draft3Validator, *args, **kwargs):
970-
"""
971-
Validate an ``instance`` under the given ``schema``.
972-
973-
>>> validate([2, 3, 4], {"maxItems" : 2})
974-
Traceback (most recent call last):
975-
...
976-
ValidationError: [2, 3, 4] is too long
977-
978-
:func:`validate` will first verify that the provided schema is itself
979-
valid, since not doing so can lead to less obvious error messages and fail
980-
in less obvious or consistent ways. If you know you have a valid schema
981-
already or don't care, you might prefer using the ``validate`` method
982-
directly on a specific validator (e.g. :meth:`Draft3Validator.validate`).
983-
984-
``cls`` is a validator class that will be used to validate the instance.
985-
By default this is a draft 3 validator. Any other provided positional and
986-
keyword arguments will be provided to this class when constructing a
987-
validator.
988-
989-
:raises:
990-
:exc:`ValidationError` if the instance is invalid
991-
992-
:exc:`SchemaError` if the schema itself is invalid
993-
994-
"""
995-
996-
997970
cls.check_schema(schema)
998971
cls(schema, *args, **kwargs).validate(instance)

tox.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ commands =
99
{envpython} -m doctest jsonschema.py
1010
deps =
1111
mock
12-
nose
13-
sphinx
14-
webcolors
12+
{[testenv:py33]deps}
1513

1614
[testenv:docs]
1715
basepython = python
@@ -27,6 +25,7 @@ deps =
2725

2826
[testenv:py33]
2927
deps =
28+
isodate
3029
nose
3130
sphinx
3231
webcolors

0 commit comments

Comments
 (0)