@@ -17,18 +17,18 @@ def _reversedict(dict_to_reverse: dict) -> dict:
17
17
return {value : key for key , value in dict_to_reverse .items ()}
18
18
19
19
20
- HEX_COLOR_RE = re .compile (r"^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$" )
20
+ _HEX_COLOR_RE = re .compile (r"^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$" )
21
21
22
22
HTML4 = "html4"
23
23
CSS2 = "css2"
24
24
CSS21 = "css21"
25
25
CSS3 = "css3"
26
26
27
- SUPPORTED_SPECIFICATIONS = (HTML4 , CSS2 , CSS21 , CSS3 )
27
+ _SUPPORTED_SPECIFICATIONS = (HTML4 , CSS2 , CSS21 , CSS3 )
28
28
29
- SPECIFICATION_ERROR_TEMPLATE = (
29
+ _SPECIFICATION_ERROR_TEMPLATE = (
30
30
f"{{spec}} is not a supported specification for color name lookups; "
31
- f"supported specifications are: { SUPPORTED_SPECIFICATIONS } ."
31
+ f"supported specifications are: { _SUPPORTED_SPECIFICATIONS } ."
32
32
)
33
33
34
34
# Mappings of color names to normalized hexadecimal color values.
@@ -43,7 +43,7 @@ def _reversedict(dict_to_reverse: dict) -> dict:
43
43
# The file tests/definitions.py in the source distribution of this module downloads a
44
44
# copy of the HTML 4 standard and parses out the color names to ensure the values below
45
45
# are correct.
46
- HTML4_NAMES_TO_HEX = {
46
+ _HTML4_NAMES_TO_HEX = {
47
47
"aqua" : "#00ffff" ,
48
48
"black" : "#000000" ,
49
49
"blue" : "#0000ff" ,
@@ -63,10 +63,10 @@ def _reversedict(dict_to_reverse: dict) -> dict:
63
63
}
64
64
65
65
# CSS2 used the same list as HTML 4.
66
- CSS2_NAMES_TO_HEX = HTML4_NAMES_TO_HEX
66
+ _CSS2_NAMES_TO_HEX = _HTML4_NAMES_TO_HEX
67
67
68
68
# CSS2.1 added orange.
69
- CSS21_NAMES_TO_HEX = {"orange" : "#ffa500" , ** HTML4_NAMES_TO_HEX }
69
+ _CSS21_NAMES_TO_HEX = {"orange" : "#ffa500" , ** _HTML4_NAMES_TO_HEX }
70
70
71
71
# The CSS3/SVG named colors.
72
72
#
@@ -84,7 +84,7 @@ def _reversedict(dict_to_reverse: dict) -> dict:
84
84
# mapping below is to hex values instead. The file tests/definitions.py in the source
85
85
# distribution of this module downloads a copy of the CSS3 color module and parses out
86
86
# the color names to ensure the values below are correct.
87
- CSS3_NAMES_TO_HEX = {
87
+ _CSS3_NAMES_TO_HEX = {
88
88
"aliceblue" : "#f0f8ff" ,
89
89
"antiquewhite" : "#faebd7" ,
90
90
"aqua" : "#00ffff" ,
@@ -238,13 +238,13 @@ def _reversedict(dict_to_reverse: dict) -> dict:
238
238
# Mappings of normalized hexadecimal color values to color names.
239
239
# --------------------------------------------------------------------------------
240
240
241
- HTML4_HEX_TO_NAMES = _reversedict (HTML4_NAMES_TO_HEX )
241
+ _HTML4_HEX_TO_NAMES = _reversedict (_HTML4_NAMES_TO_HEX )
242
242
243
- CSS2_HEX_TO_NAMES = HTML4_HEX_TO_NAMES
243
+ _CSS2_HEX_TO_NAMES = _HTML4_HEX_TO_NAMES
244
244
245
- CSS21_HEX_TO_NAMES = _reversedict (CSS21_NAMES_TO_HEX )
245
+ _CSS21_HEX_TO_NAMES = _reversedict (_CSS21_NAMES_TO_HEX )
246
246
247
- CSS3_HEX_TO_NAMES = _reversedict (CSS3_NAMES_TO_HEX )
247
+ _CSS3_HEX_TO_NAMES = _reversedict (_CSS3_NAMES_TO_HEX )
248
248
249
249
# CSS3 defines both "gray" and "grey", as well as defining either spelling variant for
250
250
# other related colors like "darkgray"/"darkgrey", etc. For a "forward" lookup from
@@ -253,27 +253,27 @@ def _reversedict(dict_to_reverse: dict) -> dict:
253
253
#
254
254
# Since "gray" was the only spelling supported in HTML 4, CSS1, and CSS2, "gray" and its
255
255
# variants are chosen here.
256
- CSS3_HEX_TO_NAMES ["#a9a9a9" ] = "darkgray"
257
- CSS3_HEX_TO_NAMES ["#2f4f4f" ] = "darkslategray"
258
- CSS3_HEX_TO_NAMES ["#696969" ] = "dimgray"
259
- CSS3_HEX_TO_NAMES ["#808080" ] = "gray"
260
- CSS3_HEX_TO_NAMES ["#d3d3d3" ] = "lightgray"
261
- CSS3_HEX_TO_NAMES ["#778899" ] = "lightslategray"
262
- CSS3_HEX_TO_NAMES ["#708090" ] = "slategray"
256
+ _CSS3_HEX_TO_NAMES ["#a9a9a9" ] = "darkgray"
257
+ _CSS3_HEX_TO_NAMES ["#2f4f4f" ] = "darkslategray"
258
+ _CSS3_HEX_TO_NAMES ["#696969" ] = "dimgray"
259
+ _CSS3_HEX_TO_NAMES ["#808080" ] = "gray"
260
+ _CSS3_HEX_TO_NAMES ["#d3d3d3" ] = "lightgray"
261
+ _CSS3_HEX_TO_NAMES ["#778899" ] = "lightslategray"
262
+ _CSS3_HEX_TO_NAMES ["#708090" ] = "slategray"
263
263
264
264
265
265
_names_to_hex = {
266
- HTML4 : HTML4_NAMES_TO_HEX ,
267
- CSS2 : CSS2_NAMES_TO_HEX ,
268
- CSS21 : CSS21_NAMES_TO_HEX ,
269
- CSS3 : CSS3_NAMES_TO_HEX ,
266
+ HTML4 : _HTML4_NAMES_TO_HEX ,
267
+ CSS2 : _CSS2_NAMES_TO_HEX ,
268
+ CSS21 : _CSS21_NAMES_TO_HEX ,
269
+ CSS3 : _CSS3_NAMES_TO_HEX ,
270
270
}
271
271
272
272
_hex_to_names = {
273
- HTML4 : HTML4_HEX_TO_NAMES ,
274
- CSS2 : CSS2_HEX_TO_NAMES ,
275
- CSS21 : CSS21_HEX_TO_NAMES ,
276
- CSS3 : CSS3_HEX_TO_NAMES ,
273
+ HTML4 : _HTML4_HEX_TO_NAMES ,
274
+ CSS2 : _CSS2_HEX_TO_NAMES ,
275
+ CSS21 : _CSS21_HEX_TO_NAMES ,
276
+ CSS3 : _CSS3_HEX_TO_NAMES ,
277
277
}
278
278
279
279
@@ -284,8 +284,8 @@ def _get_name_to_hex_map(spec: str):
284
284
:raises ValueError: when the given spec is not supported.
285
285
286
286
"""
287
- if spec not in SUPPORTED_SPECIFICATIONS :
288
- raise ValueError (SPECIFICATION_ERROR_TEMPLATE .format (spec = spec ))
287
+ if spec not in _SUPPORTED_SPECIFICATIONS :
288
+ raise ValueError (_SPECIFICATION_ERROR_TEMPLATE .format (spec = spec ))
289
289
return _names_to_hex [spec ]
290
290
291
291
@@ -296,6 +296,6 @@ def _get_hex_to_name_map(spec: str):
296
296
:raises ValueError: when the given spec is not supported.
297
297
298
298
"""
299
- if spec not in SUPPORTED_SPECIFICATIONS :
300
- raise ValueError (SPECIFICATION_ERROR_TEMPLATE .format (spec = spec ))
299
+ if spec not in _SUPPORTED_SPECIFICATIONS :
300
+ raise ValueError (_SPECIFICATION_ERROR_TEMPLATE .format (spec = spec ))
301
301
return _hex_to_names [spec ]
0 commit comments