]>
Commit | Line | Data |
---|---|---|
39795331 JB |
1 | From 09595a50f507399bf3fa8c68ed6371c42b9c4874 Mon Sep 17 00:00:00 2001 |
2 | From: Julian Berman <Julian@GrayVines.com> | |
3 | Date: Fri, 21 Feb 2020 09:30:05 -0500 | |
4 | Subject: [PATCH] Newer webcolors has a new API apparently. | |
5 | ||
6 | --- | |
7 | jsonschema/_format.py | 2 +- | |
8 | setup.cfg | 4 ++-- | |
9 | 2 files changed, 3 insertions(+), 3 deletions(-) | |
10 | ||
11 | diff --git a/jsonschema/_format.py b/jsonschema/_format.py | |
12 | index 281a7cfc..f3c758c4 100644 | |
13 | --- a/jsonschema/_format.py | |
14 | +++ b/jsonschema/_format.py | |
15 | @@ -354,7 +354,7 @@ def is_css_color_code(instance): | |
16 | def is_css21_color(instance): | |
17 | if ( | |
18 | not isinstance(instance, str_types) or | |
19 | - instance.lower() in webcolors.css21_names_to_hex | |
20 | + instance.lower() in webcolors.CSS21_NAMES_TO_HEX | |
21 | ): | |
22 | return True | |
23 | return is_css_color_code(instance) | |
24 | #diff --git a/setup.cfg b/setup.cfg | |
25 | #index 250c15be..a75c1150 100644 | |
26 | #--- a/setup.cfg | |
27 | #+++ b/setup.cfg | |
28 | #@@ -40,11 +40,11 @@ format = | |
29 | # jsonpointer>1.13 | |
30 | # rfc3987 | |
31 | # strict-rfc3339 | |
32 | #- webcolors | |
33 | #+ webcolors>=1.11.1 | |
34 | # format_nongpl = | |
35 | # idna | |
36 | # jsonpointer>1.13 | |
37 | #- webcolors | |
38 | #+ webcolors>=1.11.1 | |
39 | # rfc3986-validator>0.1.0 | |
40 | # rfc3339-validator | |
41 | # | |
42 | From 0d192e192526252c30c16b3651c293bb5f21a99f Mon Sep 17 00:00:00 2001 | |
43 | From: Julian Berman <Julian@GrayVines.com> | |
44 | Date: Fri, 21 Feb 2020 09:56:13 -0500 | |
45 | Subject: [PATCH] Sigh... but also drops Py2 compat. | |
46 | ||
47 | --- | |
48 | jsonschema/_format.py | 11 ++++++++--- | |
49 | setup.cfg | 4 ++-- | |
50 | 2 files changed, 10 insertions(+), 5 deletions(-) | |
51 | ||
52 | diff --git a/jsonschema/_format.py b/jsonschema/_format.py | |
53 | index f3c758c4..b96efb69 100644 | |
54 | --- a/jsonschema/_format.py | |
55 | +++ b/jsonschema/_format.py | |
56 | @@ -342,10 +342,15 @@ def is_draft3_time(instance): | |
57 | return datetime.datetime.strptime(instance, "%H:%M:%S") | |
58 | ||
59 | ||
60 | -try: | |
61 | +try: # webcolors>=1.11 | |
62 | + from webcolors import CSS21_NAMES_TO_HEX | |
63 | import webcolors | |
64 | except ImportError: | |
65 | - pass | |
66 | + try: # webcolors<1.11 | |
67 | + from webcolors import css21_names_to_hex as CSS21_NAMES_TO_HEX | |
68 | + import webcolors | |
69 | + except ImportError: | |
70 | + pass | |
71 | else: | |
72 | def is_css_color_code(instance): | |
73 | return webcolors.normalize_hex(instance) | |
74 | @@ -354,7 +359,7 @@ def is_css_color_code(instance): | |
75 | def is_css21_color(instance): | |
76 | if ( | |
77 | not isinstance(instance, str_types) or | |
78 | - instance.lower() in webcolors.CSS21_NAMES_TO_HEX | |
79 | + instance.lower() in CSS21_NAMES_TO_HEX | |
80 | ): | |
81 | return True | |
82 | return is_css_color_code(instance) | |
83 | #diff --git a/setup.cfg b/setup.cfg | |
84 | #index a75c1150..250c15be 100644 | |
85 | #--- a/setup.cfg | |
86 | #+++ b/setup.cfg | |
87 | #@@ -40,11 +40,11 @@ format = | |
88 | # jsonpointer>1.13 | |
89 | # rfc3987 | |
90 | # strict-rfc3339 | |
91 | #- webcolors>=1.11.1 | |
92 | #+ webcolors | |
93 | # format_nongpl = | |
94 | # idna | |
95 | # jsonpointer>1.13 | |
96 | #- webcolors>=1.11.1 | |
97 | #+ webcolors | |
98 | # rfc3986-validator>0.1.0 | |
99 | # rfc3339-validator | |
100 | # |