webcode-tk 1.0.6__tar.gz → 1.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/PKG-INFO +1 -1
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/pyproject.toml +1 -1
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/__init__.py +1 -1
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/cascade_tools.py +1 -1
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/css_tools.py +33 -4
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/LICENSE.rst +0 -0
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/README.rst +0 -0
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/color_keywords.py +0 -0
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/color_tools.py +0 -0
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/font_tools.py +0 -0
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/html_tools.py +0 -0
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/sample_report.json +0 -0
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/ux_tools.py +0 -0
- {webcode_tk-1.0.6 → webcode_tk-1.0.9}/webcode_tk/validator_tools.py +0 -0
|
@@ -1677,7 +1677,7 @@ def get_color_contrast_details(tree: CSSAppliedTree, rating="AAA") -> list:
|
|
|
1677
1677
|
results = adjusted
|
|
1678
1678
|
else:
|
|
1679
1679
|
# It's a success! Let's let them know
|
|
1680
|
-
msg = f"
|
|
1680
|
+
msg = f"pass: {filename} passes color contrast for {rating} Normal"
|
|
1681
1681
|
msg += " and Large."
|
|
1682
1682
|
results.append(msg)
|
|
1683
1683
|
return results
|
|
@@ -93,6 +93,7 @@ class Stylesheet:
|
|
|
93
93
|
self.type = stylesheet_type
|
|
94
94
|
self.href = href
|
|
95
95
|
self.text = text
|
|
96
|
+
self.__clean_text()
|
|
96
97
|
self.nested_at_rules = []
|
|
97
98
|
self.rulesets = []
|
|
98
99
|
self.comments = []
|
|
@@ -108,6 +109,30 @@ class Stylesheet:
|
|
|
108
109
|
self.__extract_rulesets()
|
|
109
110
|
self.__set_selectors()
|
|
110
111
|
|
|
112
|
+
def __clean_text(self):
|
|
113
|
+
"""cleans up CSS like removing extra line returns
|
|
114
|
+
|
|
115
|
+
This is here because if a student has more than 2 blank lines, it
|
|
116
|
+
could trigger an attribute error (at least it did in the past)
|
|
117
|
+
"""
|
|
118
|
+
text_to_clean = self.text
|
|
119
|
+
split_text = text_to_clean.split("\n")
|
|
120
|
+
cleaned_text = ""
|
|
121
|
+
consecutive_blanks = 0
|
|
122
|
+
for line in split_text:
|
|
123
|
+
if not line:
|
|
124
|
+
consecutive_blanks += 1
|
|
125
|
+
if consecutive_blanks > 1:
|
|
126
|
+
consecutive_blanks = 1
|
|
127
|
+
continue
|
|
128
|
+
else:
|
|
129
|
+
if not line and cleaned_text:
|
|
130
|
+
cleaned_text += "\n"
|
|
131
|
+
cleaned_text += line + "\n"
|
|
132
|
+
if cleaned_text[-1:] == "\n":
|
|
133
|
+
cleaned_text = cleaned_text[:-1].strip()
|
|
134
|
+
self.text = cleaned_text
|
|
135
|
+
|
|
111
136
|
def __minify(self):
|
|
112
137
|
"""Removes all whitespace, line returns, and tabs from text."""
|
|
113
138
|
self.text = minify_code(self.text)
|
|
@@ -1260,9 +1285,10 @@ def get_declaration_value_by_property(
|
|
|
1260
1285
|
def get_families(declaration_block: DeclarationBlock) -> list:
|
|
1261
1286
|
"""returns a list of all font families in a declaration block"""
|
|
1262
1287
|
families = []
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1288
|
+
if declaration_block:
|
|
1289
|
+
for ruleset in declaration_block.declarations:
|
|
1290
|
+
if ruleset.property in ("font", "font-family"):
|
|
1291
|
+
families.append(ruleset.value)
|
|
1266
1292
|
return families
|
|
1267
1293
|
|
|
1268
1294
|
|
|
@@ -1279,7 +1305,10 @@ def get_font_families(sheet: Stylesheet) -> list:
|
|
|
1279
1305
|
"""
|
|
1280
1306
|
font_families = []
|
|
1281
1307
|
for ruleset in sheet.rulesets:
|
|
1282
|
-
|
|
1308
|
+
try:
|
|
1309
|
+
block = ruleset.declaration_block
|
|
1310
|
+
except AttributeError:
|
|
1311
|
+
continue
|
|
1283
1312
|
families = get_families(block)
|
|
1284
1313
|
if families:
|
|
1285
1314
|
# create dict of selector and family
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|