Skip to content

Commit 6407acc

Browse files
committed
rebuild and retest
1 parent d90fbbb commit 6407acc

File tree

7 files changed

+1009
-879
lines changed

7 files changed

+1009
-879
lines changed

coverage.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ tests/test_nb_fns.py ........ [100%]
1010
Name Stmts Miss Cover
1111
---------------------------------------------
1212
wvpy/__init__.py 3 0 100%
13-
wvpy/jtools.py 234 67 71%
13+
wvpy/jtools.py 262 80 69%
1414
wvpy/pysheet.py 99 99 0%
1515
wvpy/render_workbook.py 54 54 0%
1616
---------------------------------------------
17-
TOTAL 390 220 44%
17+
TOTAL 418 233 44%
1818

1919

20-
============================== 8 passed in 17.96s ==============================
20+
============================== 8 passed in 17.67s ==============================

examples/param_worksheet/run_examples.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from wvpy.jtools import JTask, job_fn
66
import imgkit
77
import pdfkit
8+
import pprint
89

910

1011
if __name__ == "__main__":
@@ -25,6 +26,8 @@
2526
{"n": 15, "d": datetime.date(2022, 8, 20)},
2627
]
2728
]
29+
print("starting tasks:")
30+
pprint.pprint(tasks)
2831
# do the work
2932
with Pool(4) as p:
3033
p.map(job_fn, tasks)

examples/param_worksheet/run_log.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
starting tasks:
2+
[JTask(
3+
sheet_name= 'ParamExample',
4+
output_suffix= '_2022-08-18_5',
5+
exclude_input= True,
6+
init_code= "\nimport datetime\nworksheet_params = {'n': 5, 'd': datetime.date(2022, 8, 18)}\n",
7+
path_prefix= None,
8+
),
9+
JTask(
10+
sheet_name= 'ParamExample',
11+
output_suffix= '_2022-08-19_10',
12+
exclude_input= True,
13+
init_code= "\nimport datetime\nworksheet_params = {'n': 10, 'd': datetime.date(2022, 8, 19)}\n",
14+
path_prefix= None,
15+
),
16+
JTask(
17+
sheet_name= 'ParamExample',
18+
output_suffix= '_2022-08-20_15',
19+
exclude_input= True,
20+
init_code= "\nimport datetime\nworksheet_params = {'n': 15, 'd': datetime.date(2022, 8, 20)}\n",
21+
path_prefix= None,
22+
)]
23+
start render_as_html "ParamExample.ipynb" "_2022-08-19_10" 2023-01-22 10:15:44.727280
24+
done render_as_html "ParamExample_2022-08-19_10.html" 2023-01-22 10:15:47.581793
25+
start render_as_html "ParamExample.ipynb" "_2022-08-20_15" 2023-01-22 10:15:44.727305
26+
done render_as_html "ParamExample_2022-08-20_15.html" 2023-01-22 10:15:47.599934
27+
start render_as_html "ParamExample.ipynb" "_2022-08-18_5" 2023-01-22 10:15:44.727987
28+
done render_as_html "ParamExample_2022-08-18_5.html" 2023-01-22 10:15:47.740577
29+
Loading page (1/2)
30+
[> ] 0%[======> ] 10%[============================> ] 48%[=============================> ] 49%[=================================================> ] 82%[======================================================> ] 90%[======================================================> ] 90%[============================================================] 100%Rendering (2/2)
31+
[> ] 0%[===============> ] 25%[============================================================] 100%Done
32+
Loading page (1/2)
33+
[> ] 0%[======> ] 10%[============================> ] 48%[=============================> ] 49%[===================================================> ] 85%[======================================================> ] 90%[======================================================> ] 90%[============================================================] 100%Rendering (2/2)
34+
[> ] 0%[===============> ] 25%[============================================================] 100%Done
35+
Loading page (1/2)
36+
[> ] 0%[======> ] 10%[============================> ] 48%[=============================> ] 49%[===================================================> ] 86%[======================================================> ] 90%[======================================================> ] 90%[============================================================] 100%Rendering (2/2)
37+
[> ] 0%[===============> ] 25%[============================================================] 100%Done

pkg/build/lib/wvpy/jtools.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import nbconvert.preprocessors
99

1010
from typing import Optional
11+
from functools import total_ordering
1112

1213
have_pdf_kit = False
1314
try:
@@ -355,6 +356,7 @@ def render_as_html(
355356
print(f'\tdone render_as_html "{html_name}" {datetime.datetime.now()}')
356357

357358

359+
@total_ordering
358360
class JTask:
359361
def __init__(
360362
self,
@@ -410,15 +412,43 @@ def render_as_html(self) -> None:
410412
init_code=self.init_code,
411413
)
412414

415+
def __getitem__(self, item):
416+
return getattr(self, item)
417+
418+
def _is_valid_operand(self, other):
419+
return isinstance(other, JTask)
420+
421+
def __eq__(self, other):
422+
if not self._is_valid_operand(other):
423+
return NotImplemented
424+
if str(type(self)) != str(type(other)):
425+
return False
426+
for v in ["sheet_name", "output_suffix", "exclude_input", "init_code", "path_prefix"]:
427+
if self[v] != other[v]:
428+
return False
429+
return True
430+
431+
def __lt__(self, other):
432+
if not self._is_valid_operand(other):
433+
return NotImplemented
434+
if str(type(self)) < str(type(other)):
435+
return True
436+
for v in ["sheet_name", "output_suffix", "exclude_input", "init_code", "path_prefix"]:
437+
v_self = self[v]
438+
v_other = other[v]
439+
# can't order compare None to None
440+
if ((v_self is None) or (v_other is None)) and ((v_self is None) != (v_other is None)):
441+
return v_self is None
442+
if self[v] < other[v]:
443+
return True
444+
return False
445+
413446
def __str__(self) -> str:
414447
args_str = ",\n".join([
415-
f" 'sheet_name': {repr(self.sheet_name)}",
416-
f" 'output_suffix': {repr(self.output_suffix)}",
417-
f" 'exclude_input': {repr(self.exclude_input)}",
418-
f" 'init_code': {repr(self.init_code)}",
419-
f" 'path_prefix': {repr(self.path_prefix)}",
448+
f" {v}= {repr(self[v])}"
449+
for v in ["sheet_name", "output_suffix", "exclude_input", "init_code", "path_prefix"]
420450
])
421-
return 'JTask(**{\n' + args_str + ",\n})"
451+
return 'JTask(\n' + args_str + ",\n)"
422452

423453
def __repr__(self) -> str:
424454
return self.__str__()
234 Bytes
Binary file not shown.

pkg/dist/wvpy-0.3.9.tar.gz

216 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)