blob: afc38a30bff0cfb0af14c30440b4d0281d406fd2 [file] [log] [blame]
Brad Bishop23eaf032019-11-20 05:15:02 -05001From 8df0332475991884b8e1801d31f9c3e06d06bf9f Mon Sep 17 00:00:00 2001
2From: Nicola Lunghi <nick83ola@gmail.com>
3Date: Thu, 14 Nov 2019 18:58:56 +0000
4Subject: [PATCH] setup.cfg: add non GPL format option
5
6This is a rewrite of the following upstream commits:
7
8 - 10f8a3e Add format validators as separate modules
9 - af37707 non GPL format option
10
11removing all the non necessary bits (tox in particular)
12
13Original author: Nicolas Aimetti <naimetti@yahoo.com.ar>
14
15Upstream-status: Backported. [ to be removed for releases > 3.1.1 ]
16---
17 jsonschema/_format.py | 33 ++++++++++++++++++++++++++++-----
18 setup.cfg | 6 ++++++
19 2 files changed, 34 insertions(+), 5 deletions(-)
20
21diff --git a/jsonschema/_format.py b/jsonschema/_format.py
22index aa04090..c967d98 100644
23--- a/jsonschema/_format.py
24+++ b/jsonschema/_format.py
25@@ -248,7 +248,26 @@ else:
26 try:
27 import rfc3987
28 except ImportError:
29- pass
30+ try:
31+ from rfc3986_validator import validate_rfc3986
32+ except ImportError:
33+ pass
34+ else:
35+ @_checks_drafts(name="uri",)
36+ def is_uri(instance):
37+ if not isinstance(instance, str_types):
38+ return True
39+ return validate_rfc3986(instance, rule="URI")
40+
41+ @_checks_drafts(
42+ draft6="uri-reference",
43+ draft7="uri-reference",
44+ raises=ValueError,
45+ )
46+ def is_uri_reference(instance):
47+ if not isinstance(instance, str_types):
48+ return True
49+ return validate_rfc3986(instance, rule="URI_reference")
50 else:
51 @_checks_drafts(draft7="iri", raises=ValueError)
52 def is_iri(instance):
53@@ -280,15 +299,19 @@ else:
54
55
56 try:
57- import strict_rfc3339
58+ from strict_rfc3339 import validate_rfc3339
59 except ImportError:
60- pass
61-else:
62+ try:
63+ from rfc3339_validator import validate_rfc3339
64+ except ImportError:
65+ validate_rfc3339 = None
66+
67+if validate_rfc3339:
68 @_checks_drafts(name="date-time")
69 def is_datetime(instance):
70 if not isinstance(instance, str_types):
71 return True
72- return strict_rfc3339.validate_rfc3339(instance)
73+ return validate_rfc3339(instance)
74
75 @_checks_drafts(draft7="time")
76 def is_time(instance):
77diff --git a/setup.cfg b/setup.cfg
78index 74bc4a7..878221c 100644
79--- a/setup.cfg
80+++ b/setup.cfg
81@@ -40,6 +40,12 @@ format =
82 rfc3987
83 strict-rfc3339
84 webcolors
85+format_nongpl =
86+ idna
87+ jsonpointer>1.13
88+ webcolors
89+ rfc3986-validator>0.1.0
90+ rfc3339-validator
91
92 [options.entry_points]
93 console_scripts =
94--
952.20.1
96