summaryrefslogtreecommitdiff
path: root/meta-openembedded/meta-python/recipes-devtools/python/python-jsonschema/0001-setup.cfg-add-non-GPL-format-option.patch
blob: afc38a30bff0cfb0af14c30440b4d0281d406fd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From 8df0332475991884b8e1801d31f9c3e06d06bf9f Mon Sep 17 00:00:00 2001
From: Nicola Lunghi <nick83ola@gmail.com>
Date: Thu, 14 Nov 2019 18:58:56 +0000
Subject: [PATCH] setup.cfg: add non GPL format option

This is a rewrite of the following upstream commits:

 - 10f8a3e Add format validators as separate modules
 - af37707 non GPL format option

removing all the non necessary bits (tox in particular)

Original author: Nicolas Aimetti <naimetti@yahoo.com.ar>

Upstream-status: Backported. [ to be removed for releases > 3.1.1 ]
---
 jsonschema/_format.py | 33 ++++++++++++++++++++++++++++-----
 setup.cfg             |  6 ++++++
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/jsonschema/_format.py b/jsonschema/_format.py
index aa04090..c967d98 100644
--- a/jsonschema/_format.py
+++ b/jsonschema/_format.py
@@ -248,7 +248,26 @@ else:
 try:
     import rfc3987
 except ImportError:
-    pass
+    try:
+        from rfc3986_validator import validate_rfc3986
+    except ImportError:
+        pass
+    else:
+        @_checks_drafts(name="uri",)
+        def is_uri(instance):
+            if not isinstance(instance, str_types):
+                return True
+            return validate_rfc3986(instance, rule="URI")
+
+        @_checks_drafts(
+            draft6="uri-reference",
+            draft7="uri-reference",
+            raises=ValueError,
+        )
+        def is_uri_reference(instance):
+            if not isinstance(instance, str_types):
+                return True
+            return validate_rfc3986(instance, rule="URI_reference")
 else:
     @_checks_drafts(draft7="iri", raises=ValueError)
     def is_iri(instance):
@@ -280,15 +299,19 @@ else:
 
 
 try:
-    import strict_rfc3339
+    from strict_rfc3339 import validate_rfc3339
 except ImportError:
-    pass
-else:
+    try:
+        from rfc3339_validator import validate_rfc3339
+    except ImportError:
+        validate_rfc3339 = None
+
+if validate_rfc3339:
     @_checks_drafts(name="date-time")
     def is_datetime(instance):
         if not isinstance(instance, str_types):
             return True
-        return strict_rfc3339.validate_rfc3339(instance)
+        return validate_rfc3339(instance)
 
     @_checks_drafts(draft7="time")
     def is_time(instance):
diff --git a/setup.cfg b/setup.cfg
index 74bc4a7..878221c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -40,6 +40,12 @@ format =
 	rfc3987
 	strict-rfc3339
 	webcolors
+format_nongpl =
+	idna
+	jsonpointer>1.13
+	webcolors
+	rfc3986-validator>0.1.0
+	rfc3339-validator
 
 [options.entry_points]
 console_scripts = 
-- 
2.20.1