encommon 0.21.0__py3-none-any.whl → 0.22.1__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 +23 -11
  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 +15 -0
  8. encommon/webkit/images/information.svg +18 -0
  9. encommon/webkit/images/success.svg +18 -0
  10. encommon/webkit/images/warning.svg +16 -0
  11. encommon/webkit/index.html +218 -0
  12. encommon/webkit/scripts/color.js +60 -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.1.dist-info}/METADATA +1 -1
  51. {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/RECORD +54 -8
  52. {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/LICENSE +0 -0
  53. {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/WHEEL +0 -0
  54. {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,60 @@
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 colordiv(
11
+ input,
12
+ label=null,
13
+ ) {
14
+ // Construct element for displaying the specified color.
15
+
16
+ assert(!isnull(input));
17
+
18
+
19
+ let element =
20
+ $('<div/>').addClass(
21
+ 'encommon_colordiv');
22
+
23
+
24
+ let known = [
25
+ 'gray',
26
+ 'red',
27
+ 'blue',
28
+ 'green',
29
+ 'yellow',
30
+ 'pink',
31
+ 'teal'];
32
+
33
+ if (known.includes(input))
34
+ input =
35
+ 'rgb(var(--color-'
36
+ + `${input}-dark))`;
37
+
38
+
39
+ let value =
40
+ $('<div/>')
41
+ .addClass('_value');
42
+
43
+ value.css(
44
+ 'background-color',
45
+ input);
46
+
47
+ element.append(value);
48
+
49
+
50
+ if (!isnull(label)) {
51
+
52
+ let _label =
53
+ $('<div/>')
54
+ .addClass('_label')
55
+ .html(label);
56
+
57
+ element.append(_label); }
58
+
59
+
60
+ return element; }
@@ -0,0 +1,105 @@
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 datagrid(
11
+ fields,
12
+ values,
13
+ ) {
14
+ // Construct the table with the header using the contents.
15
+
16
+ assert(!isnull(fields));
17
+ assert(!isnull(values));
18
+
19
+
20
+ let element =
21
+ $('<table/>').addClass(
22
+ 'encommon_datagrid');
23
+
24
+
25
+ element.append(
26
+ _table_header(fields));
27
+
28
+ element.append(
29
+ _table_records(
30
+ fields, values));
31
+
32
+
33
+ return element; }
34
+
35
+
36
+
37
+ function _table_header(
38
+ fields,
39
+ ) {
40
+ // Construct the header for use with the table contents.
41
+
42
+ let element = $('<thead/>');
43
+ let trow = $('<tr/>');
44
+
45
+
46
+ let _fields =
47
+ Object.keys(fields);
48
+
49
+ _fields.forEach(key => {
50
+
51
+ let tcell = $('<th/>');
52
+
53
+ let value = fields[key];
54
+
55
+ tcell.text(value);
56
+
57
+ trow.append(tcell); });
58
+
59
+
60
+ element.append(trow);
61
+
62
+ return element; }
63
+
64
+
65
+
66
+ function _table_records(
67
+ fields,
68
+ values,
69
+ ) {
70
+ // Construct the records for use with the table contents.
71
+
72
+ let element = $('<tbody/>');
73
+
74
+
75
+ values.forEach(record => {
76
+
77
+ let trow = $('<tr/>');
78
+
79
+
80
+ let _fields =
81
+ Object.keys(fields);
82
+
83
+ _fields.forEach(key => {
84
+
85
+ let tcell = $('<td/>');
86
+ let value = record[key];
87
+
88
+ if (isquery(value))
89
+ tcell.html(
90
+ value[0].outerHTML);
91
+
92
+ else if (isnode(value))
93
+ tcell.html(
94
+ value.outerHTML);
95
+
96
+ else if (!isnull(value))
97
+ tcell.text(value);
98
+
99
+ trow.append(tcell); });
100
+
101
+
102
+ element.append(trow); });
103
+
104
+
105
+ return element; }
@@ -0,0 +1,160 @@
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 datestamp(
11
+ value,
12
+ ) {
13
+ // Return the timestamp using provided format for instance.
14
+
15
+ assert(!isnull(value));
16
+
17
+
18
+ let element =
19
+ $('<div/>').addClass(
20
+ 'encommon_datestamp');
21
+
22
+
23
+ let date =
24
+ new Date(value);
25
+
26
+ let time =
27
+ date.getTime();
28
+
29
+ assert(time);
30
+
31
+
32
+ let pad = num =>
33
+ String(num)
34
+ .padStart(2, '0');
35
+
36
+ let source_month =
37
+ pad(date.getMonth() + 1);
38
+
39
+ let source_day =
40
+ pad(date.getDate());
41
+
42
+ let source_year =
43
+ date.getFullYear();
44
+
45
+ let source_hours =
46
+ pad(date.getHours());
47
+
48
+ let source_minutes =
49
+ pad(date.getMinutes());
50
+
51
+ let source_seconds =
52
+ pad(date.getSeconds());
53
+
54
+ let source_tzname =
55
+ _tzname(date);
56
+
57
+ if (source_tzname == 'GMT')
58
+ source_tzname = 'UTC';
59
+
60
+
61
+ element.append(
62
+ $('<span/>')
63
+ .addClass('_value')
64
+ .addClass('_year')
65
+ .text(source_year));
66
+
67
+ element.append(
68
+ $('<span/>')
69
+ .addClass('_delim')
70
+ .addClass('_slash')
71
+ .text('-'));
72
+
73
+ element.append(
74
+ $('<span/>')
75
+ .addClass('_value')
76
+ .addClass('_month')
77
+ .text(source_month));
78
+
79
+ element.append(
80
+ $('<span/>')
81
+ .addClass('_delim')
82
+ .addClass('_slash')
83
+ .text('-'));
84
+
85
+ element.append(
86
+ $('<span/>')
87
+ .addClass('_value')
88
+ .addClass('_day')
89
+ .text(source_day));
90
+
91
+ element.append(
92
+ $('<span/>')
93
+ .addClass('_delim')
94
+ .addClass('_space')
95
+ .html('&nbsp;'));
96
+
97
+ element.append(
98
+ $('<span/>')
99
+ .addClass('_value')
100
+ .addClass('_hours')
101
+ .text(source_hours));
102
+
103
+ element.append(
104
+ $('<span/>')
105
+ .addClass('_delim')
106
+ .addClass('_colon')
107
+ .text(':'));
108
+
109
+ element.append(
110
+ $('<span/>')
111
+ .addClass('_value')
112
+ .addClass('_minutes')
113
+ .text(source_minutes));
114
+
115
+ element.append(
116
+ $('<span/>')
117
+ .addClass('_delim')
118
+ .addClass('_colon')
119
+ .text(':'));
120
+
121
+ element.append(
122
+ $('<span/>')
123
+ .addClass('_value')
124
+ .addClass('_seconds')
125
+ .text(source_seconds));
126
+
127
+ element.append(
128
+ $('<span/>')
129
+ .addClass('_delim')
130
+ .addClass('_space')
131
+ .html('&nbsp;'));
132
+
133
+ element.append(
134
+ $('<span/>')
135
+ .addClass('_tzname')
136
+ .text(source_tzname));
137
+
138
+
139
+ return element; }
140
+
141
+
142
+
143
+ function _tzname(
144
+ date,
145
+ ) {
146
+ // Return the located timezone object for the provided date.
147
+
148
+ assert(!isnull(date));
149
+
150
+ let tzname =
151
+ new Intl.DateTimeFormat(
152
+ 'en-US',
153
+ {'timeZoneName': 'short'})
154
+ .formatToParts(date)
155
+ .find(
156
+ x =>
157
+ x.type === 'timeZoneName')
158
+ .value;
159
+
160
+ return tzname; }
@@ -0,0 +1,327 @@
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 (global) {
11
+ // jQuery like object for use in Enasis Network projects.
12
+
13
+ 'use strict';
14
+
15
+ global.$ = $;
16
+
17
+
18
+ function $(selector) {
19
+
20
+ if (!(this instanceof $))
21
+ return new $(selector);
22
+
23
+
24
+ if (!selector) {
25
+
26
+ this.length = 0;
27
+ this.elements = [];
28
+
29
+ return this; }
30
+
31
+
32
+ if (isquery(selector))
33
+ return selector;
34
+
35
+ else if (isnodes(selector))
36
+ this.elements = selector;
37
+
38
+ else if (isnode(selector))
39
+ this.elements = [selector];
40
+
41
+ else if (isstr(selector))
42
+ _enquery(this, selector);
43
+
44
+
45
+ this.length =
46
+ this.elements
47
+ .length;
48
+
49
+ this.elements
50
+ .forEach(
51
+ (x, y) =>
52
+ { this[y] = x; }); }
53
+
54
+
55
+ $.prototype
56
+ .enquery = true;
57
+
58
+ $.prototype
59
+ .each = _enquery_each;
60
+
61
+ $.prototype
62
+ .clone = _enquery_clone;
63
+
64
+ $.prototype
65
+ .css = _enquery_css;
66
+
67
+ $.prototype
68
+ .addClass = _enquery_addcls;
69
+
70
+ $.prototype
71
+ .remClass = _enquery_remcls;
72
+
73
+ $.prototype
74
+ .hide = _enquery_hide;
75
+
76
+ $.prototype
77
+ .show = _enquery_show;
78
+
79
+ $.prototype
80
+ .text = _enquery_text;
81
+
82
+ $.prototype
83
+ .html = _enquery_html;
84
+
85
+ $.prototype
86
+ .append = _enquery_append;
87
+
88
+ $.prototype
89
+ .replace = _enquery_replace;
90
+
91
+ $.prototype
92
+ .attr = _enquery_attr;
93
+
94
+ })(window);
95
+
96
+
97
+
98
+ function _enquery(
99
+ source,
100
+ selector,
101
+ ) {
102
+ // Helper function for Enasis Network jQuery replacement.
103
+
104
+ const create = /^<(\w+)\/>$/;
105
+
106
+ assert(isstr(selector));
107
+
108
+ if (!create.test(selector))
109
+ source.elements =
110
+ document
111
+ .querySelectorAll(selector);
112
+
113
+ else {
114
+
115
+ let tagName =
116
+ selector
117
+ .match(create)[1];
118
+
119
+ let element =
120
+ document
121
+ .createElement(tagName);
122
+
123
+ source.elements = [element]; } }
124
+
125
+
126
+
127
+ function _enquery_each(
128
+ element,
129
+ ) {
130
+ // Helper function for Enasis Network jQuery replacement.
131
+
132
+ let items = this.elements;
133
+
134
+ this.elements.forEach(
135
+ (x, y) =>
136
+ element.call(x, y, x));
137
+
138
+ return this; }
139
+
140
+
141
+
142
+ function _enquery_css(
143
+ name,
144
+ value,
145
+ ) {
146
+ // Helper function for Enasis Network jQuery replacement.
147
+
148
+ function _each() {
149
+ this.style[name] = value; }
150
+
151
+ return this.each(_each); }
152
+
153
+
154
+
155
+ function _enquery_addcls(
156
+ name,
157
+ ) {
158
+ // Helper function for Enasis Network jQuery replacement.
159
+
160
+ function _each() {
161
+ this.classList
162
+ .add(name); }
163
+
164
+ return this.each(_each); }
165
+
166
+
167
+
168
+ function _enquery_remcls(
169
+ name,
170
+ ) {
171
+ // Helper function for Enasis Network jQuery replacement.
172
+
173
+ function _each() {
174
+ this.classList
175
+ .remove(name); }
176
+
177
+ return this.each(_each); }
178
+
179
+
180
+
181
+ function _enquery_hide() {
182
+ // Helper function for Enasis Network jQuery replacement.
183
+
184
+ let returned =
185
+ this.css('display', 'none');
186
+
187
+ return returned; }
188
+
189
+
190
+
191
+ function _enquery_show() {
192
+ // Helper function for Enasis Network jQuery replacement.
193
+
194
+ let returned =
195
+ this.css('display', 'block');
196
+
197
+ return returned; }
198
+
199
+
200
+
201
+ function _enquery_text(
202
+ text,
203
+ ) {
204
+ // Helper function for Enasis Network jQuery replacement.
205
+
206
+ if (text === undefined) {
207
+
208
+ if (this.length > 0)
209
+ return this[0].textContent;
210
+
211
+ return undefined; }
212
+
213
+ else {
214
+
215
+ function _each() {
216
+ this.textContent = text; }
217
+
218
+ return this.each(_each); } }
219
+
220
+
221
+
222
+ function _enquery_html(
223
+ html,
224
+ ) {
225
+ // Helper function for Enasis Network jQuery replacement.
226
+
227
+ if (html === undefined) {
228
+
229
+ if (this.length > 0)
230
+ return this[0].innerHTML;
231
+
232
+ return undefined; }
233
+
234
+ else {
235
+
236
+ if (isquery(html))
237
+ html = html[0].outerHTML;
238
+
239
+ else if (isnode(html))
240
+ html = html.outerHTML;
241
+
242
+ function _each() {
243
+ this.innerHTML = html; }
244
+
245
+ return this.each(_each); } }
246
+
247
+
248
+
249
+ function _enquery_append(
250
+ element,
251
+ ) {
252
+ // Helper function for Enasis Network jQuery replacement.
253
+
254
+ assert(element.enquery)
255
+
256
+ let nodes = element.elements;
257
+
258
+
259
+ function _each(index) {
260
+
261
+ nodes.forEach(
262
+ (x) => {
263
+ const element =
264
+ index < 1 ?
265
+ x : node.cloneNode(true);
266
+ this
267
+ .appendChild(element); }); }
268
+
269
+
270
+ return this.each(_each); }
271
+
272
+
273
+
274
+ function _enquery_replace(
275
+ element,
276
+ ) {
277
+ // Helper function for Enasis Network jQuery replacement.
278
+
279
+ assert(element.enquery)
280
+
281
+ let nodes = element.elements;
282
+
283
+
284
+ function _each(index) {
285
+
286
+ nodes.forEach(
287
+ (x) => {
288
+ const element =
289
+ index < 1 ?
290
+ x : x.cloneNode(true);
291
+ this
292
+ .replaceChildren(element); }); }
293
+
294
+
295
+ return this.each(_each); }
296
+
297
+
298
+
299
+ function _enquery_attr(
300
+ name,
301
+ value,
302
+ ) {
303
+ // Helper function for Enasis Network jQuery replacement.
304
+
305
+ if (this.length === 0)
306
+ return undefined;
307
+
308
+ if (value !== undefined)
309
+ this[0]
310
+ .setAttribute(name, value);
311
+
312
+ let returned =
313
+ this[0]
314
+ .getAttribute(name);
315
+
316
+ return returned; }
317
+
318
+
319
+
320
+ function _enquery_clone() {
321
+
322
+ let clones =
323
+ Array
324
+ .from(this.elements)
325
+ .map(x => x.cloneNode(true));
326
+
327
+ return $(clones); }