encommon 0.21.0__py3-none-any.whl → 0.22.0__py3-none-any.whl

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.
Files changed (54) hide show
  1. encommon/times/common.py +3 -0
  2. encommon/times/unitime.py +17 -8
  3. encommon/version.txt +1 -1
  4. encommon/webkit/__init__.py +15 -0
  5. encommon/webkit/content.py +94 -0
  6. encommon/webkit/images/enasis.svg +174 -0
  7. encommon/webkit/images/failure.svg +14 -0
  8. encommon/webkit/images/information.svg +17 -0
  9. encommon/webkit/images/success.svg +17 -0
  10. encommon/webkit/images/warning.svg +15 -0
  11. encommon/webkit/index.html +218 -0
  12. encommon/webkit/scripts/color.js +45 -0
  13. encommon/webkit/scripts/datagrid.js +105 -0
  14. encommon/webkit/scripts/datetime.js +160 -0
  15. encommon/webkit/scripts/default.js +327 -0
  16. encommon/webkit/scripts/duration.js +150 -0
  17. encommon/webkit/scripts/helpers.js +247 -0
  18. encommon/webkit/scripts/image.js +39 -0
  19. encommon/webkit/scripts/message.js +31 -0
  20. encommon/webkit/scripts/moderate.js +71 -0
  21. encommon/webkit/scripts/numeric.js +189 -0
  22. encommon/webkit/scripts/statate.js +35 -0
  23. encommon/webkit/scripts/tagues.js +34 -0
  24. encommon/webkit/styles/color.css +57 -0
  25. encommon/webkit/styles/datagrid.css +58 -0
  26. encommon/webkit/styles/datetime.css +50 -0
  27. encommon/webkit/styles/default.css +204 -0
  28. encommon/webkit/styles/duration.css +44 -0
  29. encommon/webkit/styles/image.css +60 -0
  30. encommon/webkit/styles/message.css +88 -0
  31. encommon/webkit/styles/moderate.css +64 -0
  32. encommon/webkit/styles/numeric.css +55 -0
  33. encommon/webkit/styles/statate.css +50 -0
  34. encommon/webkit/styles/tagues.css +45 -0
  35. encommon/webkit/test/__init__.py +39 -0
  36. encommon/webkit/test/conftest.py +52 -0
  37. encommon/webkit/test/test_color.py +64 -0
  38. encommon/webkit/test/test_content.py +98 -0
  39. encommon/webkit/test/test_datagrid.py +90 -0
  40. encommon/webkit/test/test_datetime.py +75 -0
  41. encommon/webkit/test/test_default.py +314 -0
  42. encommon/webkit/test/test_duration.py +74 -0
  43. encommon/webkit/test/test_helpers.py +382 -0
  44. encommon/webkit/test/test_image.py +62 -0
  45. encommon/webkit/test/test_message.py +64 -0
  46. encommon/webkit/test/test_moderate.py +75 -0
  47. encommon/webkit/test/test_numeric.py +164 -0
  48. encommon/webkit/test/test_statate.py +78 -0
  49. encommon/webkit/test/test_tagues.py +66 -0
  50. {encommon-0.21.0.dist-info → encommon-0.22.0.dist-info}/METADATA +1 -1
  51. {encommon-0.21.0.dist-info → encommon-0.22.0.dist-info}/RECORD +54 -8
  52. {encommon-0.21.0.dist-info → encommon-0.22.0.dist-info}/LICENSE +0 -0
  53. {encommon-0.21.0.dist-info → encommon-0.22.0.dist-info}/WHEEL +0 -0
  54. {encommon-0.21.0.dist-info → encommon-0.22.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,247 @@
1
+ /*
2
+ Functions and routines associated with Enasis Network Common Library.
3
+
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
+ */
7
+
8
+
9
+
10
+ function assert(
11
+ condition,
12
+ ) {
13
+ // Assert the provided condition similar how using Python.
14
+
15
+ if (condition)
16
+ return true;
17
+
18
+ throw new Error('Assertion'); }
19
+
20
+
21
+
22
+ function whenready(
23
+ callback,
24
+ ) {
25
+ // Attach the callback to the window session ready state.
26
+
27
+ assert(!isnull(callback));
28
+
29
+ let state =
30
+ document.readyState;
31
+
32
+ if (state == 'loading')
33
+ document
34
+ .addEventListener(
35
+ 'DOMContentLoaded',
36
+ callback);
37
+
38
+ else callback(); }
39
+
40
+
41
+
42
+ function isnull(
43
+ value,
44
+ ) {
45
+ // Return the boolean indicating the conditional outcome.
46
+
47
+ let haystack = [null, undefined];
48
+
49
+ if (haystack.includes(value))
50
+ return true;
51
+
52
+ return false; }
53
+
54
+
55
+
56
+ function isempty(
57
+ value,
58
+ ) {
59
+ // Return the boolean indicating the conditional outcome.
60
+
61
+ if (isstr(value))
62
+ return value.length == 0;
63
+
64
+ if (isdict(value)) {
65
+
66
+ let keys =
67
+ Object.keys(value)
68
+ .length;
69
+
70
+ if (length == 0)
71
+ return true; }
72
+
73
+ if (islist(value))
74
+ return value.length == 0;
75
+
76
+ return isnull(value); }
77
+
78
+
79
+
80
+ function isbool(
81
+ value,
82
+ ) {
83
+ // Return the boolean indicating the conditional outcome.
84
+
85
+ let haystack = [true, false];
86
+
87
+ if (haystack.includes(value))
88
+ return true;
89
+
90
+ return false; }
91
+
92
+
93
+
94
+ function isstr(
95
+ value,
96
+ ) {
97
+ // Return the boolean indicating the conditional outcome.
98
+
99
+ if (typeof value === 'string')
100
+ return true;
101
+
102
+ return false; }
103
+
104
+
105
+
106
+ function isnum(
107
+ value,
108
+ ) {
109
+ // Return the boolean indicating the conditional outcome.
110
+
111
+ if (typeof value === 'number')
112
+ return true;
113
+
114
+ return false; }
115
+
116
+
117
+
118
+ function isquery(
119
+ value,
120
+ ) {
121
+ // Return the boolean indicating the conditional outcome.
122
+
123
+ try {
124
+
125
+ if (value.enquery)
126
+ return true; }
127
+
128
+ catch (e) { }
129
+
130
+ return false; }
131
+
132
+
133
+
134
+ function isnode(
135
+ value,
136
+ ) {
137
+ // Return the boolean indicating the conditional outcome.
138
+
139
+ if (value instanceof Node)
140
+ return true;
141
+
142
+ return false; }
143
+
144
+
145
+
146
+ function isnodes(
147
+ value,
148
+ ) {
149
+ // Return the boolean indicating the conditional outcome.
150
+
151
+ if (value instanceof NodeList)
152
+ return true;
153
+
154
+ return false; }
155
+
156
+
157
+
158
+ function istime(
159
+ value,
160
+ ) {
161
+ // Return the boolean indicating the conditional outcome.
162
+
163
+ let date =
164
+ new Date(value);
165
+
166
+ if (!isNaN(date.getTime()))
167
+ return true;
168
+
169
+ return false; }
170
+
171
+
172
+
173
+ function islist(
174
+ value,
175
+ ) {
176
+ // Return the boolean indicating the conditional outcome.
177
+
178
+ if (Array.isArray(value))
179
+ return true;
180
+
181
+ return false; }
182
+
183
+
184
+
185
+ function isdict(
186
+ value,
187
+ ) {
188
+ // Return the boolean indicating the conditional outcome.
189
+
190
+ if (typeof(value) == 'object'
191
+ && !isnull(value)
192
+ && !Array.isArray(value))
193
+ return true;
194
+
195
+ return false; }
196
+
197
+
198
+
199
+ function istrue(
200
+ value,
201
+ ) {
202
+ // Return the boolean indicating the conditional outcome.
203
+
204
+ if (value === true)
205
+ return true;
206
+
207
+ return false; }
208
+
209
+
210
+
211
+ function isfalse(
212
+ value,
213
+ ) {
214
+ // Return the boolean indicating the conditional outcome.
215
+
216
+ if (value === false)
217
+ return true;
218
+
219
+ return false; }
220
+
221
+
222
+
223
+ function loads(
224
+ value,
225
+ ) {
226
+ // Return the object value from the provided JSON string.
227
+
228
+ assert(isstr(value));
229
+
230
+ return JSON.parse(value); }
231
+
232
+
233
+
234
+ function dumps(
235
+ value,
236
+ indent=null,
237
+ ) {
238
+ // Return the JSON string from the provided object value.
239
+
240
+ assert(!isnull(value));
241
+ assert(!isstr(value));
242
+
243
+ let returned =
244
+ JSON.stringify(
245
+ value, null, indent);
246
+
247
+ return returned; }
@@ -0,0 +1,39 @@
1
+ /*
2
+ Functions and routines associated with Enasis Network Common Library.
3
+
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
+ */
7
+
8
+
9
+
10
+ function svgicon(
11
+ image,
12
+ dimension=null,
13
+ ) {
14
+ // Return the simple construct for SVG based icon images.
15
+
16
+ assert(!isnull(image));
17
+
18
+
19
+ let element =
20
+ $('<div/>').addClass(
21
+ 'encommon_svgicon');
22
+
23
+
24
+ element.attr(
25
+ 'data-image',
26
+ image);
27
+
28
+ if (!isnull(dimension)) {
29
+
30
+ element.css(
31
+ 'height',
32
+ dimension);
33
+
34
+ element.css(
35
+ 'width',
36
+ dimension); }
37
+
38
+
39
+ return element; }
@@ -0,0 +1,31 @@
1
+ /*
2
+ Functions and routines associated with Enasis Network Common Library.
3
+
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
+ */
7
+
8
+
9
+
10
+ function message(
11
+ level,
12
+ about=null,
13
+ ) {
14
+ // Generate the severity based toast like message element.
15
+
16
+ assert(!isnull(level));
17
+
18
+
19
+ let element =
20
+ $('<div/>').addClass(
21
+ 'encommon_message');
22
+
23
+
24
+ element.attr(
25
+ 'data-level',
26
+ level);
27
+
28
+ element.html(about);
29
+
30
+
31
+ return element; }
@@ -0,0 +1,71 @@
1
+ /*
2
+ Functions and routines associated with Enasis Network Common Library.
3
+
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
+ */
7
+
8
+
9
+
10
+ function moderate(
11
+ label=null,
12
+ icon=null,
13
+ small=null,
14
+ ) {
15
+ // Construct for containing a wide variety of value types.
16
+
17
+
18
+ let element =
19
+ $('<div/>').addClass(
20
+ 'encommon_moderate');
21
+
22
+
23
+ if (!isnull(icon)) {
24
+
25
+ if (isstr(icon))
26
+ icon = svgicon(icon);
27
+
28
+ let _icon =
29
+ $('<div/>')
30
+ .addClass('_icon')
31
+ .replace(icon);
32
+
33
+ element.append(_icon); }
34
+
35
+
36
+ let value =
37
+ $('<div/>')
38
+ .addClass('_value');
39
+
40
+
41
+ let _value = false;
42
+
43
+ if (!isnull(label)) {
44
+
45
+ let _label =
46
+ $('<div/>')
47
+ .addClass('_label')
48
+ .html(label);
49
+
50
+ value.append(_label);
51
+
52
+ _value = true; }
53
+
54
+
55
+ if (!isnull(small)) {
56
+
57
+ let _small =
58
+ $('<div/>')
59
+ .addClass('_small')
60
+ .html(small);
61
+
62
+ value.append(_small);
63
+
64
+ _value = true; }
65
+
66
+
67
+ if (istrue(_value))
68
+ element.append(value);
69
+
70
+
71
+ return element; }
@@ -0,0 +1,189 @@
1
+ /*
2
+ Functions and routines associated with Enasis Network Common Library.
3
+
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
+ */
7
+
8
+
9
+
10
+ function numeric(
11
+ value,
12
+ unit=null,
13
+ ) {
14
+ // Construct for containing a wide variety of value types.
15
+
16
+ assert(!isnull(value));
17
+
18
+
19
+ let element =
20
+ $('<div/>').addClass(
21
+ 'encommon_numeric');
22
+
23
+
24
+ if (!isnum(value))
25
+ value =
26
+ parseFloat(value);
27
+
28
+ value = Number(
29
+ value.toFixed(1));
30
+
31
+
32
+ let parts =
33
+ value.toString()
34
+ .split('.');
35
+
36
+
37
+ element.append(
38
+ $('<span/>')
39
+ .addClass('_value')
40
+ .text(parts[0]));
41
+
42
+
43
+ if (parts.length == 2) {
44
+
45
+ element.append(
46
+ $('<span/>')
47
+ .addClass('_delim')
48
+ .text('.'));
49
+
50
+ element.append(
51
+ $('<span/>')
52
+ .addClass('_decimal')
53
+ .text(parts[1])); }
54
+
55
+
56
+ if (!isnull(unit))
57
+
58
+ element.append(
59
+ $('<span/>')
60
+ .addClass('_unit')
61
+ .html(unit));
62
+
63
+
64
+ return element; }
65
+
66
+
67
+
68
+ function numeric_count(
69
+ value,
70
+ ) {
71
+ // Construct for containing a wide variety of value types.
72
+
73
+ assert(!isnull(value));
74
+
75
+
76
+ if (!isnum(value))
77
+ value =
78
+ parseFloat(value);
79
+
80
+ let unit = '';
81
+
82
+ if (value >= 1e12) {
83
+ value /= 1e12;
84
+ unit = 'trillion'; }
85
+
86
+ else if (value >= 1e9) {
87
+ value /= 1e9;
88
+ unit = 'billion'; }
89
+
90
+ else if (value >= 1e6) {
91
+ value /= 1e6;
92
+ unit = 'million'; }
93
+
94
+ else if (value >= 1e3) {
95
+ value /= 1e3;
96
+ unit = 'thousand'; }
97
+
98
+
99
+ let element =
100
+ numeric(value, unit);
101
+
102
+
103
+ return element; }
104
+
105
+
106
+
107
+ function numeric_bytes(
108
+ value,
109
+ ) {
110
+ // Construct for containing a wide variety of value types.
111
+
112
+ assert(!isnull(value));
113
+
114
+
115
+ if (!isnum(value))
116
+ value =
117
+ parseFloat(value);
118
+
119
+ let unit = 'B';
120
+
121
+ if (value >= 1e12) {
122
+ value /= 1e12;
123
+ unit = 'TB'; }
124
+
125
+ else if (value >= 1e9) {
126
+ value /= 1e9;
127
+ unit = 'GB'; }
128
+
129
+ else if (value >= 1e6) {
130
+ value /= 1e6;
131
+ unit = 'MB'; }
132
+
133
+ else if (value >= 1e3) {
134
+ value /= 1e3;
135
+ unit = 'KB'; }
136
+
137
+
138
+ let element =
139
+ numeric(value, unit);
140
+
141
+
142
+ return element; }
143
+
144
+
145
+
146
+ function numeric_ftemp(
147
+ value,
148
+ ) {
149
+ // Construct for containing a wide variety of value types.
150
+
151
+ assert(!isnull(value));
152
+
153
+
154
+ if (!isnum(value))
155
+ value =
156
+ parseFloat(value);
157
+
158
+ let unit = '°F';
159
+
160
+
161
+ let element =
162
+ numeric(value, unit);
163
+
164
+
165
+ return element; }
166
+
167
+
168
+
169
+ function numeric_cftemp(
170
+ value,
171
+ ) {
172
+ // Construct for containing a wide variety of value types.
173
+
174
+ assert(!isnull(value));
175
+
176
+
177
+ if (!isnum(value))
178
+ value =
179
+ parseFloat(value);
180
+
181
+ value = value * (9 / 5);
182
+ value += 32;
183
+
184
+
185
+ let element =
186
+ numeric_ftemp(value);
187
+
188
+
189
+ return element; }
@@ -0,0 +1,35 @@
1
+ /*
2
+ Functions and routines associated with Enasis Network Common Library.
3
+
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
+ */
7
+
8
+
9
+
10
+ function statate(
11
+ status,
12
+ label=null,
13
+ small=null,
14
+ ) {
15
+ // Construct for containing the value status information.
16
+
17
+ assert(!isnull(status));
18
+
19
+
20
+ let element =
21
+ moderate(
22
+ label,
23
+ svgicon(status),
24
+ small);
25
+
26
+
27
+ element.addClass(
28
+ 'encommon_statate');
29
+
30
+ element.attr(
31
+ 'data-status',
32
+ status);
33
+
34
+
35
+ return element; }
@@ -0,0 +1,34 @@
1
+ /*
2
+ Functions and routines associated with Enasis Network Common Library.
3
+
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
+ */
7
+
8
+
9
+
10
+ function tagues(
11
+ values,
12
+ brafter=true,
13
+ ) {
14
+ // Construct for containing the values that are tag like.
15
+
16
+ assert(!isnull(values));
17
+
18
+
19
+ let element =
20
+ $('<div/>').addClass(
21
+ 'encommon_tagues');
22
+
23
+
24
+ if (!islist(values))
25
+ values = [values];
26
+
27
+ for (const x of values)
28
+ element.append(
29
+ $('<div/>')
30
+ .addClass('_value')
31
+ .text(x));
32
+
33
+
34
+ return element; }
@@ -0,0 +1,57 @@
1
+ /*
2
+ Functions and routines associated with Enasis Network Common Library.
3
+
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
+ */
7
+
8
+
9
+
10
+ /********************************************/
11
+ /* Standard structure for colordiv elements */
12
+ /********************************************/
13
+
14
+ div.encommon_colordiv {
15
+ display: inline-block; }
16
+
17
+
18
+
19
+ /********************************************/
20
+ /* Extended structure for colordiv elements */
21
+ /********************************************/
22
+
23
+ div.encommon_colordiv
24
+ >._value {
25
+ border-width: .2rem .2rem .2rem .2rem;
26
+ border-style: solid;
27
+ border-color: rgba(var(--foreground), 0.4);
28
+ display: inline-block;
29
+ border-radius: .5rem .5rem .5rem .5rem;
30
+ height: 1.8rem;
31
+ width: 1.8rem; }
32
+
33
+
34
+
35
+ /********************************************/
36
+ /* Extended structure for colordiv elements */
37
+ /********************************************/
38
+
39
+ div.encommon_colordiv
40
+ >._label {
41
+ background-color: rgba(var(--foreground), .2);
42
+ border-radius: .2rem .2rem .2rem .2rem;
43
+ display: inline-block;
44
+ font-size: 1rem;
45
+ line-height: 1rem;
46
+ margin-left: .2rem;
47
+ padding: .2rem .3rem .2rem .3rem; }
48
+
49
+
50
+
51
+ /********************************************/
52
+ /* Extended structure for datagrid elements */
53
+ /********************************************/
54
+
55
+ table.encommon_datagrid
56
+ >tbody>tr>td:has(.encommon_colordiv) {
57
+ text-align: center; }