webcode-tk 1.2.0__tar.gz → 1.2.1__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.2.0 → webcode_tk-1.2.1}/PKG-INFO +1 -1
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/pyproject.toml +1 -1
- webcode_tk-1.2.1/webcode_tk/__init__.py +38 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/animation_tools.py +114 -63
- webcode_tk-1.2.0/webcode_tk/__init__.py +0 -27
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/LICENSE.rst +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/README.rst +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/cascade_tools.py +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/color_keywords.py +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/color_tools.py +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/css_tools.py +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/font_tools.py +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/html_tools.py +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/sample_report.json +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/utils.py +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/ux_tools.py +0 -0
- {webcode_tk-1.2.0 → webcode_tk-1.2.1}/webcode_tk/validator_tools.py +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# __init__.py
|
|
2
|
+
"""Deals with html and css documents to check their code.
|
|
3
|
+
|
|
4
|
+
### Modules exported by this package:
|
|
5
|
+
|
|
6
|
+
- **`animation_tools`**: a library used to report back on animations applied.
|
|
7
|
+
As of now, we are focusing entirely on keyframe animations (not)
|
|
8
|
+
transitions.
|
|
9
|
+
|
|
10
|
+
- **`cascade_tools`**: library to calculate how the cascade affects font-size
|
|
11
|
+
and background color and color through inheritance and will be
|
|
12
|
+
used for calculating color contrast.
|
|
13
|
+
|
|
14
|
+
- **`color_keywords`**: helper library to align color keywords with their
|
|
15
|
+
properties and hex and rgb values.
|
|
16
|
+
|
|
17
|
+
- **`color_tools`**: processes CSS color related properties and values.
|
|
18
|
+
|
|
19
|
+
- **`css_tools`**: creates Stylesheet objects that store CSS information.
|
|
20
|
+
|
|
21
|
+
- **`font_tools`**: A collection of functions used to process font-related
|
|
22
|
+
styles.
|
|
23
|
+
|
|
24
|
+
- **`html_tools`**: gets html files from a project folder, gets the HTML code
|
|
25
|
+
from files, gets number of a particular element in a file
|
|
26
|
+
or folder, gets elements as tags, and much more.
|
|
27
|
+
|
|
28
|
+
- **`ux_tools`**: gets readability stats for paragraphs of text (could
|
|
29
|
+
be from just `p` tags or a list of other tags e.g. `li`,
|
|
30
|
+
`div`, etc.).
|
|
31
|
+
|
|
32
|
+
- **`utils.py`**: a library of helper functions to reduce the workload of the
|
|
33
|
+
other libraries.
|
|
34
|
+
|
|
35
|
+
- **`validator_tools`**: sends HTML or CSS code to the W3C Validator to check
|
|
36
|
+
for errors.
|
|
37
|
+
"""
|
|
38
|
+
__version__ = "1.2.1"
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
A group of functions that work with css_tools and cascade_tools to provide
|
|
3
3
|
reports on CSS animations.
|
|
4
4
|
"""
|
|
5
|
+
from typing import Union
|
|
6
|
+
|
|
5
7
|
from file_clerk import clerk
|
|
6
8
|
|
|
7
9
|
from webcode_tk import css_tools
|
|
@@ -118,46 +120,84 @@ def get_keyframe_data(report: list) -> dict:
|
|
|
118
120
|
|
|
119
121
|
|
|
120
122
|
def get_keyframe_report(
|
|
121
|
-
|
|
123
|
+
project_folder: str, num_goal: int, pct_goal=None, from_to_goals=None
|
|
122
124
|
) -> list:
|
|
123
|
-
"""returns a list of pass/fail messages (1 for each file)
|
|
125
|
+
"""returns a list of pass/fail messages (1 for each goal in each file).
|
|
126
|
+
|
|
127
|
+
A report that allows you to set the minimum number of keyframes for each
|
|
128
|
+
file. By setting num_goal, you are stating how many keyframes in all you
|
|
129
|
+
expect to see in a project.
|
|
130
|
+
|
|
131
|
+
You can also set a minimum number of percentage keyframes, and the minimum
|
|
132
|
+
number of from {} and to {} keyframes.
|
|
133
|
+
|
|
134
|
+
NOTE: for every goal, there will be a report on that goal (one for each
|
|
135
|
+
file). If your project has two files, and you set all three goals (
|
|
136
|
+
num_goal, pct_goal, and from_to_goals), the report will create a list of
|
|
137
|
+
6 messages.
|
|
124
138
|
|
|
125
139
|
Args:
|
|
126
|
-
|
|
127
|
-
|
|
140
|
+
project_folder: the folder that houses the project.
|
|
141
|
+
num_goal: the minimum number of keyframes per file (overall)
|
|
128
142
|
pct_goal: the minimum number of percentage keyframes we would want
|
|
129
143
|
to see.
|
|
130
|
-
|
|
131
|
-
the minimum number of percentage keyframes.
|
|
144
|
+
from_to_goals: the minimum number of from and to keyframes.
|
|
132
145
|
|
|
133
146
|
Returns:
|
|
134
147
|
results: a list of messages (one for each file in the project) with
|
|
135
148
|
a pass or fail with number present of each type.
|
|
136
149
|
"""
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
report = []
|
|
151
|
+
animation_report = get_animation_report(project_folder)
|
|
152
|
+
keyframe_results = get_keyframe_data(animation_report)
|
|
153
|
+
for file, results in keyframe_results.items():
|
|
154
|
+
pct_keyframes, froms, tos = results.values()
|
|
140
155
|
msg = ""
|
|
141
156
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
157
|
+
num_pct = len(pct_keyframes)
|
|
158
|
+
num_froms_tos = froms + tos
|
|
159
|
+
overall_num = num_pct + num_froms_tos
|
|
160
|
+
if overall_num >= num_goal:
|
|
161
|
+
msg = f"pass: {file} has {overall_num} keyframes (enough "
|
|
162
|
+
msg += "overall to meet)."
|
|
145
163
|
else:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
164
|
+
remaining = num_goal - overall_num
|
|
165
|
+
msg = f"fail: {file} has only {overall_num} keyframes (needs "
|
|
166
|
+
msg += f"{remaining} more to pass)."
|
|
167
|
+
report.append(msg)
|
|
168
|
+
if pct_goal:
|
|
169
|
+
if num_pct >= pct_goal:
|
|
170
|
+
msg = f"pass: {file} has {pct_keyframes} percentage "
|
|
171
|
+
msg += "keyframes."
|
|
172
|
+
else:
|
|
173
|
+
msg = f"fail: {file} does not have enough percentage "
|
|
174
|
+
msg += "keyframes to pass."
|
|
175
|
+
report.append(msg)
|
|
176
|
+
if from_to_goals:
|
|
177
|
+
if num_froms_tos >= from_to_goals:
|
|
178
|
+
msg = f"pass: {file} has {num_froms_tos} from and to "
|
|
179
|
+
msg += "keyframes."
|
|
151
180
|
else:
|
|
152
|
-
msg = f"fail: {file} does not have enough
|
|
153
|
-
|
|
154
|
-
|
|
181
|
+
msg = f"fail: {file} does not have enough from and to "
|
|
182
|
+
msg += "keyframes to pass."
|
|
183
|
+
report.append(msg)
|
|
184
|
+
return report
|
|
155
185
|
|
|
156
186
|
|
|
157
187
|
def get_animation_properties_report(
|
|
158
|
-
|
|
159
|
-
):
|
|
160
|
-
"""returns a list of pass/fail messages
|
|
188
|
+
project_folder: str, num_goal: int, specific_properties=None
|
|
189
|
+
) -> list:
|
|
190
|
+
"""returns a list of pass/fail messages based on number and type of
|
|
191
|
+
unique animation keyframe properties.
|
|
192
|
+
|
|
193
|
+
You can specify just the number of unique properties or you can specify
|
|
194
|
+
both the number as well as check for specific targetted properties. If you
|
|
195
|
+
specify both, both must be met for a pass.
|
|
196
|
+
|
|
197
|
+
NOTE: In the case of the transform properties, you can just specify
|
|
198
|
+
transform, or you can include the type of transform in the form of
|
|
199
|
+
transform- + the transform value (eg. transform-rotate(),
|
|
200
|
+
transform-translate(), transfrom-skew(), etc.)
|
|
161
201
|
|
|
162
202
|
Since animation_values might have multiple entries for the same file,
|
|
163
203
|
we need to track a per file record to see if it meets or not.
|
|
@@ -174,54 +214,46 @@ def get_animation_properties_report(
|
|
|
174
214
|
results: a list of messages (one for each file in the project) with
|
|
175
215
|
a pass or fail with number present of each type.
|
|
176
216
|
"""
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
217
|
+
report = []
|
|
218
|
+
animation_report = get_animation_report(project_folder)
|
|
219
|
+
for item in animation_report:
|
|
220
|
+
filename = utils.get_first_dict_key(item)
|
|
221
|
+
properties_targetted = item[filename].get("properties")
|
|
222
|
+
num_properties = len(properties_targetted)
|
|
223
|
+
num_remaining = num_goal - num_properties
|
|
224
|
+
if num_remaining > 0:
|
|
225
|
+
msg = f"fail: {filename} did not target enough properties; should"
|
|
226
|
+
msg += f"target {num_remaining} properties more."
|
|
227
|
+
report.append(msg)
|
|
228
|
+
else:
|
|
184
229
|
if specific_properties:
|
|
185
230
|
# make sure it's a list
|
|
186
231
|
msg = get_targetted_properties_msg(
|
|
187
|
-
specific_properties, properties_targetted,
|
|
232
|
+
specific_properties, properties_targetted, filename
|
|
188
233
|
)
|
|
189
|
-
|
|
234
|
+
report.append(msg)
|
|
190
235
|
else:
|
|
191
236
|
# Now lets check for num of unique properties
|
|
192
237
|
msg = get_num_properties_msg(
|
|
193
|
-
num_goal, properties_targetted,
|
|
238
|
+
num_goal, properties_targetted, filename
|
|
194
239
|
)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
# will need to change the key on the animations_values list
|
|
202
|
-
properties = item.get("values_targetted")
|
|
203
|
-
for property in properties:
|
|
204
|
-
# add only unique properties
|
|
205
|
-
properties_targetted.add(property)
|
|
206
|
-
|
|
207
|
-
# process the current file (now that we're done looping)
|
|
208
|
-
# check to see if there are any required properties
|
|
209
|
-
if specific_properties:
|
|
210
|
-
# make sure it's a list
|
|
211
|
-
msg = get_targetted_properties_msg(
|
|
212
|
-
specific_properties, properties_targetted, current_file
|
|
213
|
-
)
|
|
214
|
-
results.append(msg)
|
|
215
|
-
else:
|
|
216
|
-
# Now lets check for num of unique properties
|
|
217
|
-
msg = get_num_properties_msg(
|
|
218
|
-
num_goal, properties_targetted, current_file
|
|
219
|
-
)
|
|
220
|
-
results.append(msg)
|
|
221
|
-
return results
|
|
240
|
+
report.append(msg)
|
|
241
|
+
|
|
242
|
+
# now is the time to restart our list of properties
|
|
243
|
+
properties_targetted = set()
|
|
244
|
+
return report
|
|
245
|
+
|
|
222
246
|
|
|
247
|
+
def get_num_properties_msg(
|
|
248
|
+
num_goal: int,
|
|
249
|
+
properties_targetted: Union[list, tuple, set],
|
|
250
|
+
current_file: str,
|
|
251
|
+
) -> str:
|
|
252
|
+
"""Returns a pass/fail message based on whether a file targets the min
|
|
253
|
+
number of properties found.
|
|
223
254
|
|
|
224
|
-
|
|
255
|
+
Args:
|
|
256
|
+
num_goal: the number of unique properties that should be targetted"""
|
|
225
257
|
num_unique_props = len(properties_targetted)
|
|
226
258
|
if num_unique_props >= num_goal:
|
|
227
259
|
msg = f"pass: {current_file}'s animations targetted the minimum "
|
|
@@ -235,8 +267,27 @@ def get_num_properties_msg(num_goal, properties_targetted, current_file):
|
|
|
235
267
|
|
|
236
268
|
|
|
237
269
|
def get_targetted_properties_msg(
|
|
238
|
-
properties,
|
|
239
|
-
|
|
270
|
+
properties: Union[list, tuple],
|
|
271
|
+
properties_targetted: Union[list, tuple],
|
|
272
|
+
current_file: str,
|
|
273
|
+
) -> str:
|
|
274
|
+
"""returns whether the file addresses all targetted keyframe properties or
|
|
275
|
+
not.
|
|
276
|
+
|
|
277
|
+
Receives the keyframe properties found in a file's styles and returns a
|
|
278
|
+
message that states whether the file has targetted all required properties
|
|
279
|
+
in the form of "pass" or "fail".
|
|
280
|
+
|
|
281
|
+
Args:
|
|
282
|
+
properties: a list or tuple of the keyframe properties targetted in a
|
|
283
|
+
file's stylesheets or not.
|
|
284
|
+
properties_targetted: a list or tuple of the properties that the file
|
|
285
|
+
should contain.
|
|
286
|
+
current_file: the name of the HTML document we are checking.
|
|
287
|
+
|
|
288
|
+
Returns:
|
|
289
|
+
msg: a string that begins with 'pass:' or 'fail:', and details on what
|
|
290
|
+
was missing if a fail."""
|
|
240
291
|
properties = list(properties)
|
|
241
292
|
for property in properties_targetted:
|
|
242
293
|
if property in properties:
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# __init__.py
|
|
2
|
-
"""Deals with html and css documents to check their code.
|
|
3
|
-
|
|
4
|
-
Modules exported by this package:
|
|
5
|
-
- `animation_tools`: a library used to report back on animations applied. As
|
|
6
|
-
of now, we are focusing entirely on keyframe animations (not)
|
|
7
|
-
transitions.
|
|
8
|
-
- `cascade_tools`: library to calculate how the cascade affects font-size
|
|
9
|
-
and background color and color through inheritance and will be
|
|
10
|
-
used for calculating color contrast.
|
|
11
|
-
- `color_keywords`: helper library to align color keywords with their
|
|
12
|
-
properties and hex and rgb values.
|
|
13
|
-
- `color_tools`: processes CSS color related properties and values.
|
|
14
|
-
- `css_tools`: creates Stylesheet objects that store CSS information.
|
|
15
|
-
- `font_tools`: A collection of functions used to process font-related styles.
|
|
16
|
-
- `html_tools`: gets html files from a project folder, gets the HTML code
|
|
17
|
-
from files, gets number of a particular element in a file
|
|
18
|
-
or folder, gets elements as tags, and much more.
|
|
19
|
-
- `ux_tools`: gets readability stats for paragraphs of text (could
|
|
20
|
-
be from just `p` tags or a list of other tags e.g. `li`,
|
|
21
|
-
`div`, etc.).
|
|
22
|
-
- `utils.py`: a library of helper functions to reduce the workload of the
|
|
23
|
-
other libraries.
|
|
24
|
-
- `validator_tools`: sends HTML or CSS code to the W3C Validator to check
|
|
25
|
-
for errors.
|
|
26
|
-
"""
|
|
27
|
-
__version__ = "1.2.0"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|