encommon 1.0.1__py3-none-any.whl → 1.1.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
encommon/config/common.py CHANGED
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
encommon/config/config.py CHANGED
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
encommon/config/files.py CHANGED
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
encommon/config/logger.py CHANGED
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
encommon/config/paths.py CHANGED
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
@@ -16,7 +16,7 @@ from ..logger import Logger
16
16
  from ..logger import Message
17
17
  from ...times.common import UNIXEPOCH
18
18
  from ...times.common import UNIXMPOCH
19
- from ...utils import strip_ansi
19
+ from ...utils.stdout import strip_ansi
20
20
 
21
21
 
22
22
 
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
encommon/conftest.py CHANGED
@@ -1,8 +1,8 @@
1
1
  """
2
2
  Functions and routines associated with Enasis Network Common Library.
3
3
 
4
- This file is part of Enasis Network software eco-system. Distribution is
5
- permitted, for more information consult the project license file.
4
+ This file is part of Enasis Network software eco-system. Distribution
5
+ is permitted, for more information consult the project license file.
6
6
  """
7
7
 
8
8
 
encommon/times/parse.py CHANGED
@@ -240,6 +240,8 @@ def since_time(
240
240
 
241
241
  def duration(
242
242
  seconds: int,
243
+ compact: bool = True,
244
+ maximum: int = 6,
243
245
  ) -> str:
244
246
  """
245
247
  Convert provided the seconds into a human friendly format.
@@ -249,32 +251,54 @@ def duration(
249
251
  >>> duration(86400 * 700)
250
252
  '1y11mon5d'
251
253
 
254
+ Example
255
+ -------
256
+ >>> duration(86400 * 700, False, 2)
257
+ '1 year, 11 months'
258
+
252
259
  :param seconds: Period in seconds that will be iterated.
260
+ :param compact: Determines if output will be condensed.
261
+ :param maximum: Determines how many time units are shown.
262
+ Default value happens to be same number of time units
263
+ supported; year, month, week, day, hour, and minute.
253
264
  :returns: Human friendly format from the value in seconds.
254
265
  """
255
266
 
256
267
  if seconds < 60:
257
- return f'{seconds}s'
268
+ return (
269
+ f'{seconds}s' if compact
270
+ else 'just now')
258
271
 
259
272
  groups = (
260
- ('y', 31536000),
261
- ('mon', 2592000),
262
- ('w', 604800),
263
- ('d', 86400),
264
- ('h', 3600),
265
- ('m', 60))
273
+ ('year', 'y', 31536000),
274
+ ('month', 'mon', 2592000),
275
+ ('week', 'w', 604800),
276
+ ('day', 'd', 86400),
277
+ ('hour', 'h', 3600),
278
+ ('minute', 'm', 60))
266
279
 
267
- returned = []
280
+ returned: list[str] = []
268
281
 
269
- for key, value in groups:
282
+ delimiter = '' if compact else ', '
283
+
284
+ for long, short, value in groups:
270
285
 
271
286
  if seconds < value:
272
287
  continue
273
288
 
274
289
  _value = seconds // value
275
290
 
291
+ key = short if compact else long
292
+
293
+ if not compact:
294
+ key = (
295
+ f' {key}' if _value == 1
296
+ else f' {key}s')
297
+
276
298
  returned.append(f'{_value}{key}')
277
299
 
278
300
  seconds %= value
279
301
 
280
- return ''.join(returned)
302
+ returned = returned[:maximum]
303
+
304
+ return delimiter.join(returned)
@@ -223,35 +223,59 @@ def test_duration() -> None:
223
223
  quarter = day * 90
224
224
  year = day * 365
225
225
 
226
- expects = {
227
226
 
228
- year - 1: '12mon4d23h59m',
229
- year: '1y',
230
- year + 1: '1y',
227
+ expects = {
231
228
 
232
- quarter - 1: '2mon4w1d23h59m',
233
- quarter: '3mon',
234
- quarter + 1: '3mon',
229
+ year: ('1y', '1 year'),
230
+ year + 1: ('1y', '1 year'),
231
+ year - 1: (
232
+ '12mon4d23h59m',
233
+ '12 months, 4 days'),
234
+
235
+ quarter: ('3mon', '3 months'),
236
+ quarter + 1: ('3mon', '3 months'),
237
+ quarter - 1: (
238
+ '2mon4w1d23h59m',
239
+ '2 months, 4 weeks'),
240
+
241
+ month: ('1mon', '1 month'),
242
+ month + 1: ('1mon', '1 month'),
243
+ month - 1: (
244
+ '4w1d23h59m',
245
+ '4 weeks, 1 day'),
246
+
247
+ week: ('1w', '1 week'),
248
+ week + 1: ('1w', '1 week'),
249
+ week - 1: (
250
+ '6d23h59m',
251
+ '6 days, 23 hours'),
252
+
253
+ day: ('1d', '1 day'),
254
+ day + 1: ('1d', '1 day'),
255
+ day - 1: (
256
+ '23h59m',
257
+ '23 hours, 59 minutes'),
258
+
259
+ hour: ('1h', '1 hour'),
260
+ hour + 1: ('1h', '1 hour'),
261
+ hour - 1: ('59m', '59 minutes'),
262
+
263
+ second: ('1m', '1 minute'),
264
+ second + 1: ('1m', '1 minute'),
265
+ second - 1: ('59s', 'just now')}
235
266
 
236
- month - 1: '4w1d23h59m',
237
- month: '1mon',
238
- month + 1: '1mon',
239
267
 
240
- week - 1: '6d23h59m',
241
- week: '1w',
242
- week + 1: '1w',
268
+ for source, expect in expects.items():
243
269
 
244
- day - 1: '23h59m',
245
- day: '1d',
246
- day + 1: '1d',
270
+ durated = duration(
271
+ seconds=source,
272
+ compact=True)
247
273
 
248
- hour - 1: '59m',
249
- hour: '1h',
250
- hour + 1: '1h',
274
+ assert durated == expect[0]
251
275
 
252
- second - 1: '59s',
253
- second: '1m',
254
- second + 1: '1m'}
276
+ durated = duration(
277
+ seconds=source,
278
+ compact=False,
279
+ maximum=2)
255
280
 
256
- for source, expect in expects.items():
257
- assert duration(source) == expect
281
+ assert durated == expect[1]
encommon/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.1
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: encommon
3
- Version: 1.0.1
3
+ Version: 1.1.1
4
4
  Summary: Enasis Network Common Library
5
5
  License: MIT
6
6
  Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Python :: 3.10
7
8
  Classifier: Programming Language :: Python :: 3.11
8
- Requires-Python: >=3.11
9
+ Requires-Python: >=3.10
9
10
  Description-Content-Type: text/markdown
10
11
  License-File: LICENSE
11
12
  Requires-Dist: croniter
@@ -19,7 +20,8 @@ Requires-Dist: snaptime
19
20
  [![Validate](https://github.com/enasisnetwork/encommon/actions/workflows/build.yml/badge.svg)](https://github.com/enasisnetwork/encommon/actions/workflows/build.yml)
20
21
  [![Documentation Status](https://readthedocs.org/projects/encommon/badge/?version=latest)](https://encommon.readthedocs.io/en/latest/?badge=latest)
21
22
 
22
- Common classes and functions used in various public and private projects for [Enasis Network](https://github.com/enasisnetwork).
23
+ Common classes and functions used in various public and private projects for
24
+ [Enasis Network](https://github.com/enasisnetwork).
23
25
 
24
26
  ## Installing the package
25
27
  ```
@@ -28,8 +30,8 @@ pip install encommon
28
30
 
29
31
  ## Documentation
30
32
  Documentation can be found on [Read the Docs](https://encommon.readthedocs.io).
31
- However if you venture into the sections below you will be able to use the
32
- `sphinx` recipe to build the documention in `docs/html` for local viewing.
33
+ If you venture into the sections below you will be able to use the `sphinx`
34
+ recipe to build the documention in `docs/html` for local consumption.
33
35
 
34
36
  ## Quick start for local development
35
37
  Start by cloning the repository to your local machine.
@@ -42,7 +44,8 @@ make -s venv-create
42
44
  ```
43
45
 
44
46
  ### Execute the linters and tests
45
- The comprehensive approach is to use the `check` recipe. This will stop on any failure that is encountered.
47
+ The comprehensive approach is to use the `check` recipe. This will stop on any
48
+ failure that is encountered.
46
49
  ```
47
50
  make -s check
48
51
  ```
@@ -55,3 +58,13 @@ information found in the `htmlcov` folder in the root of the project.
55
58
  ```
56
59
  make -s pytest
57
60
  ```
61
+
62
+ ## Future features and subpackages
63
+
64
+ ### `netdom` subpackage
65
+ This package will include class objects for handling network addresses and
66
+ other functions to assist with validating and normalizing domain names.
67
+
68
+ ### `formats` subpackage
69
+ This package will include class objects to help with dealing with verious
70
+ formats of data. These formats will include Jinja2, CSV, and HTML.
@@ -1,19 +1,19 @@
1
1
  encommon/__init__.py,sha256=VoXUcphq-gcXCraaU47EtXBftF6UVuQPMGr0fuCTt9A,525
2
- encommon/conftest.py,sha256=OkzXA-CdP3RiFqhtaL3nF5Qdt0LFsajrQaOZ_3BWaQo,772
2
+ encommon/conftest.py,sha256=D_8TAxCdBXYyUacz6V5Iovgka7mn7pXH_rBcx8xbLEg,772
3
3
  encommon/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- encommon/version.txt,sha256=ROFh5ElcrCz3hYBD6eZBjpV58N3ProJvmjcmIpaM4GY,6
5
- encommon/config/__init__.py,sha256=ZimcFRtWo22L_fKgfVnY8YcwkVQ_DeC3AV_3TVO-Z1c,469
6
- encommon/config/common.py,sha256=gWJ3usayN6yKNdXikFoM4Y0lmQTphkV7-2xJmVFo4SA,1961
7
- encommon/config/config.py,sha256=VnxPHPz5rKqQ-T6HqffMBUvEoqlR1dykH_F_yqgTqik,4282
8
- encommon/config/files.py,sha256=2aqv0kfM26xQBZ38D7bzN9pH-cnX0vYlfmfbkI-PKDs,1535
9
- encommon/config/logger.py,sha256=dQe5JQy0hWH-7skK_mSmGb9hOBikR0o8pWMGoNYrqQs,13510
10
- encommon/config/paths.py,sha256=9T5upahVfUZ8zYDo8AU2ab5ESvORUs2LVXjj3PsSsHM,1729
11
- encommon/config/test/__init__.py,sha256=ieWgzVdaxhiaP_GnfdCtcSEaRW56vnpKXVsCLhqaask,218
12
- encommon/config/test/test_common.py,sha256=Jr3myDlIPKy-rKUOaX_awjGwD1PJZsf1ZSiK6XIvqXc,731
13
- encommon/config/test/test_config.py,sha256=e5MUkQmL9xAueAezBkciPDFqGP9hDNyM7Bt0JylNhHg,3196
14
- encommon/config/test/test_files.py,sha256=uxNUXtn3qhsdokixEb20P2Y1IOSMQICk6_uNGyQlhb4,1300
15
- encommon/config/test/test_logger.py,sha256=7kdhGsza0_9IBOHrs36sTuOeU8KFkQCMwJuSTVz75MQ,4359
16
- encommon/config/test/test_paths.py,sha256=IWkp2Xyaxs9IIx33nfPyhN_9FCdSsp8FFxMmP2XcNSQ,1167
4
+ encommon/version.txt,sha256=zFL2eISLgUNzdXtGA4O_YZYOSUPCA3Na3eCjULPlCYk,6
5
+ encommon/config/__init__.py,sha256=tCvJrBTdtNSyg3sZkwUFQBwtK8QHgxLQl833OxblKAo,469
6
+ encommon/config/common.py,sha256=_DEkMJnIftu4opDzvfOEdwQ6DF66nenS4mmtQKctVNA,1961
7
+ encommon/config/config.py,sha256=F9ptyCX-IqTc-UrC9JhP6zWESeOPJkpECjnhdh82ynA,4282
8
+ encommon/config/files.py,sha256=RlAk9iCH7JNYubDQe7IeenKuPY1l8h-DCPcmw2Qv9fI,1535
9
+ encommon/config/logger.py,sha256=B3c7WQQcyWgUIFYu0h4k5YFE75PADwaUyTAGFUVxi_A,13510
10
+ encommon/config/paths.py,sha256=NIt4jQy2SalEXuOyZqSdin_3LzLADsqp44bH8tm8RQU,1729
11
+ encommon/config/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
12
+ encommon/config/test/test_common.py,sha256=U6XWfCLxtLmArn8P6h4cmCALzdXxV7IMUxKNU-UhwPw,731
13
+ encommon/config/test/test_config.py,sha256=D0RsIH9rQaf2OLN9vUzbGsszRXNbc7pBK7n6LySDyD0,3196
14
+ encommon/config/test/test_files.py,sha256=KUdPUvDzBPL9jTRTjJ5nRUOti5i8Z_MF1aBTSHUpmLM,1300
15
+ encommon/config/test/test_logger.py,sha256=Ya0lVnOB97M6FTRwxbmcKcULUGW_nPt4bLCdSRHbTQI,4366
16
+ encommon/config/test/test_paths.py,sha256=SlDJnUeW9JK9Hu3B-QCdHadwPDeqdfzqa-73YYbeefQ,1167
17
17
  encommon/crypt/__init__.py,sha256=y8TS6RKrKseH6mMSjEULrVkl6-KbevH0yZiWmIWj1UA,315
18
18
  encommon/crypt/crypt.py,sha256=MvKTUv2CnHqEofODzJWI-dropZULKQlVSJ6Y7BJQzHc,3147
19
19
  encommon/crypt/hashes.py,sha256=PNw-leN3Mx2U1-aVrjK2ueK3b2qXwwXj4rLEMC85DpY,2797
@@ -22,13 +22,13 @@ encommon/crypt/test/test_crypt.py,sha256=iiIIvQ8YaegpKsfcAxs-zbFh7qyrGrh8A7b_Q9z
22
22
  encommon/crypt/test/test_hashes.py,sha256=Q6OUtDe6-lWS31x6-YdjPqaxLQ4yBUAeA04qXjSanC4,1086
23
23
  encommon/times/__init__.py,sha256=Yr6rd_bflwOR4XcYkJ3bKKO4HoWI4d8G8PH7eAEfKkc,591
24
24
  encommon/times/common.py,sha256=zDI5ztMkfLmV090jlLLK3hFzGGveasy8I_wNfOQDScg,2500
25
- encommon/times/parse.py,sha256=Th24yCy7tRJoUpCuoP7tuJlwsqHSkTEw7_FES_3tMpU,7168
25
+ encommon/times/parse.py,sha256=ffk-Az5nF24EFE1xbkh9Jp-JjTlTp1hRf8AKTXeZ8pQ,7917
26
26
  encommon/times/timer.py,sha256=dsxGgxQ-I75nnwcY9qdxuYD6TdCbhof2KvJuPcatimw,3200
27
27
  encommon/times/times.py,sha256=xpaZ1F25VHj6s862doLQWqmPf9yrj1lkN-BILRH3sPw,8947
28
28
  encommon/times/window.py,sha256=Fx_OJfU9B0IctCyaJ5XH_HxzhGlzeRATwuhI-HlsTPA,8023
29
29
  encommon/times/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
30
30
  encommon/times/test/test_common.py,sha256=nizxgB1scLDEm2o66waK1Ar_Dl5BBMTC-GRV7iDk0_U,1477
31
- encommon/times/test/test_parse.py,sha256=23DPaAvoRaXPVRMlxzxev2iYk2hcnHNl6kWPEhdn4MQ,5242
31
+ encommon/times/test/test_parse.py,sha256=AhOblR9xN3BUTc4Em-hD432hVECnCWE1OmmYM_fZsmU,5911
32
32
  encommon/times/test/test_timer.py,sha256=hGpvUt3Hz0v-OfWZtU8gRhkGCEFJ12LV2b5MVzb-PDs,1407
33
33
  encommon/times/test/test_times.py,sha256=hiDdsbrRhj0E5-XO_2EHXdhca73jdiP3rcK2mPbNkSg,1954
34
34
  encommon/times/test/test_window.py,sha256=AX2xIjtzSrXUe9MTci69z-1Si0Tw5ZHdLS7WB69Qw_A,4829
@@ -49,8 +49,8 @@ encommon/utils/test/test_paths.py,sha256=ZPU84G_vI13G6t-PtDhM9UG4SHOoF4TiEdqApxt
49
49
  encommon/utils/test/test_regexp.py,sha256=oJglz-8TJiSUtE7NuseFy0dVjau2jR1foEj-ZsBlcek,697
50
50
  encommon/utils/test/test_sample.py,sha256=EZnRI27qf7x3s7Xbtkd9t0o_y1xDQB0o2sPxbO0_dDQ,1465
51
51
  encommon/utils/test/test_stdout.py,sha256=a060uA8oEHFGoVqdwB5iYxdl4R2TRSgr6Z7pMEbxibs,1675
52
- encommon-1.0.1.dist-info/LICENSE,sha256=04XJC5i4LRUf1A_U1EGCMJLpGodnmOFlh30yu7FAVfs,1071
53
- encommon-1.0.1.dist-info/METADATA,sha256=2tbrkbopSDaELQpAgJFiM2sBM1TCL8lBnIZkjUgm50k,1869
54
- encommon-1.0.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
55
- encommon-1.0.1.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
56
- encommon-1.0.1.dist-info/RECORD,,
52
+ encommon-1.1.1.dist-info/LICENSE,sha256=04XJC5i4LRUf1A_U1EGCMJLpGodnmOFlh30yu7FAVfs,1071
53
+ encommon-1.1.1.dist-info/METADATA,sha256=oG0BIP6K8ILaeVJxVOC2x2Rs3W5T70Fk9pxttBaGyGo,2291
54
+ encommon-1.1.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
55
+ encommon-1.1.1.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
56
+ encommon-1.1.1.dist-info/RECORD,,