utilo 2.106.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.
- utilo-2.106.1/PKG-INFO +32 -0
- utilo-2.106.1/README +9 -0
- utilo-2.106.1/setup.cfg +4 -0
- utilo-2.106.1/setup.py +84 -0
- utilo-2.106.1/tests/test_collection.py +38 -0
- utilo-2.106.1/tests/test_convert.py +33 -0
- utilo-2.106.1/tests/test_datetime.py +29 -0
- utilo-2.106.1/tests/test_decorators.py +37 -0
- utilo-2.106.1/tests/test_error.py +91 -0
- utilo-2.106.1/tests/test_file.py +596 -0
- utilo-2.106.1/tests/test_import.py +15 -0
- utilo-2.106.1/tests/test_likelihood.py +112 -0
- utilo-2.106.1/tests/test_logger.py +208 -0
- utilo-2.106.1/tests/test_math.py +75 -0
- utilo-2.106.1/tests/test_pages.py +174 -0
- utilo-2.106.1/tests/test_process.py +98 -0
- utilo-2.106.1/tests/test_quick.py +30 -0
- utilo-2.106.1/tests/test_regex.py +25 -0
- utilo-2.106.1/tests/test_string.py +74 -0
- utilo-2.106.1/tests/test_todo.py +47 -0
- utilo-2.106.1/tests/test_typechecker.py +37 -0
- utilo-2.106.1/tests/test_utils.py +144 -0
- utilo-2.106.1/tests/test_yaml.py +25 -0
- utilo-2.106.1/utilo/__init__.py +529 -0
- utilo-2.106.1/utilo/__todo__.py +93 -0
- utilo-2.106.1/utilo/alpha.py +142 -0
- utilo-2.106.1/utilo/baw.py +66 -0
- utilo-2.106.1/utilo/cacher.py +187 -0
- utilo-2.106.1/utilo/classes.py +49 -0
- utilo-2.106.1/utilo/classifier/__init__.py +8 -0
- utilo-2.106.1/utilo/classifier/base.py +113 -0
- utilo-2.106.1/utilo/classifier/public.py +219 -0
- utilo-2.106.1/utilo/classifier/strategy.py +108 -0
- utilo-2.106.1/utilo/cli/__init__.py +642 -0
- utilo-2.106.1/utilo/collection.py +429 -0
- utilo-2.106.1/utilo/color.py +30 -0
- utilo-2.106.1/utilo/config.py +64 -0
- utilo-2.106.1/utilo/convert.py +204 -0
- utilo-2.106.1/utilo/datetime.py +68 -0
- utilo-2.106.1/utilo/decorator.py +90 -0
- utilo-2.106.1/utilo/error.py +72 -0
- utilo-2.106.1/utilo/feature/__init__.py +8 -0
- utilo-2.106.1/utilo/feature/cache.py +141 -0
- utilo-2.106.1/utilo/feature/collector.py +103 -0
- utilo-2.106.1/utilo/feature/config.py +68 -0
- utilo-2.106.1/utilo/feature/cprofile.py +24 -0
- utilo-2.106.1/utilo/feature/description.py +106 -0
- utilo-2.106.1/utilo/feature/outpath.py +199 -0
- utilo-2.106.1/utilo/feature/pack.py +359 -0
- utilo-2.106.1/utilo/feature/path.py +41 -0
- utilo-2.106.1/utilo/feature/processor.py +427 -0
- utilo-2.106.1/utilo/feature/userinput.py +147 -0
- utilo-2.106.1/utilo/feature/workplan.py +547 -0
- utilo-2.106.1/utilo/file/__init__.py +738 -0
- utilo-2.106.1/utilo/file/action.py +229 -0
- utilo-2.106.1/utilo/file/directory.py +83 -0
- utilo-2.106.1/utilo/file/hashed.py +42 -0
- utilo-2.106.1/utilo/file/info.py +94 -0
- utilo-2.106.1/utilo/file/loader.py +173 -0
- utilo-2.106.1/utilo/file/securewrapper.py +127 -0
- utilo-2.106.1/utilo/file/utils.py +79 -0
- utilo-2.106.1/utilo/group.py +181 -0
- utilo-2.106.1/utilo/hash.py +40 -0
- utilo-2.106.1/utilo/likelihood.py +120 -0
- utilo-2.106.1/utilo/logger.py +413 -0
- utilo-2.106.1/utilo/math/__init__.py +314 -0
- utilo-2.106.1/utilo/math/const.py +71 -0
- utilo-2.106.1/utilo/math/distance.py +44 -0
- utilo-2.106.1/utilo/math/func.py +36 -0
- utilo-2.106.1/utilo/math/line.py +263 -0
- utilo-2.106.1/utilo/math/near.py +130 -0
- utilo-2.106.1/utilo/math/number.py +177 -0
- utilo-2.106.1/utilo/math/rectangle.py +409 -0
- utilo-2.106.1/utilo/math/roman.py +204 -0
- utilo-2.106.1/utilo/optimizer.py +71 -0
- utilo-2.106.1/utilo/pages.py +492 -0
- utilo-2.106.1/utilo/process.py +368 -0
- utilo-2.106.1/utilo/quick.py +192 -0
- utilo-2.106.1/utilo/regex.py +57 -0
- utilo-2.106.1/utilo/secret.py +68 -0
- utilo-2.106.1/utilo/space.py +99 -0
- utilo-2.106.1/utilo/string/__init__.py +482 -0
- utilo-2.106.1/utilo/string/compare.py +77 -0
- utilo-2.106.1/utilo/string/display.py +47 -0
- utilo-2.106.1/utilo/string/modify.py +58 -0
- utilo-2.106.1/utilo/string/table.py +110 -0
- utilo-2.106.1/utilo/tuples.py +161 -0
- utilo-2.106.1/utilo/typechecker.py +390 -0
- utilo-2.106.1/utilo/utils.py +695 -0
- utilo-2.106.1/utilo/xyz/__init__.py +8 -0
- utilo-2.106.1/utilo/xyz/lock.py +39 -0
- utilo-2.106.1/utilo/xyz/table.py +171 -0
- utilo-2.106.1/utilo/xyz/tidy.py +62 -0
- utilo-2.106.1/utilo.egg-info/PKG-INFO +32 -0
- utilo-2.106.1/utilo.egg-info/SOURCES.txt +98 -0
- utilo-2.106.1/utilo.egg-info/dependency_links.txt +1 -0
- utilo-2.106.1/utilo.egg-info/entry_points.txt +5 -0
- utilo-2.106.1/utilo.egg-info/not-zip-safe +1 -0
- utilo-2.106.1/utilo.egg-info/top_level.txt +2 -0
- utilo-2.106.1/utilotest/__init__.py +360 -0
utilo-2.106.1/PKG-INFO
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: utilo
|
|
3
|
+
Version: 2.106.1
|
|
4
|
+
Summary: write it once
|
|
5
|
+
Home-page: https://github.com/anaticulae/utilo
|
|
6
|
+
Author: Helmut Konrad Schewe
|
|
7
|
+
Author-email: helmutus@outlook.com
|
|
8
|
+
Platform: any
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: platform
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
UTILA
|
|
25
|
+
=====
|
|
26
|
+
|
|
27
|
+
utila is the base package which include redundant functionality for the
|
|
28
|
+
project. The most common steps are implemented in this package to reduce the
|
|
29
|
+
amount of code.
|
|
30
|
+
|
|
31
|
+
>>> import utilo
|
|
32
|
+
>>> utilo.file_read('README)
|
utilo-2.106.1/README
ADDED
utilo-2.106.1/setup.cfg
ADDED
utilo-2.106.1/setup.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#==============================================================================
|
|
3
|
+
# C O P Y R I G H T
|
|
4
|
+
#------------------------------------------------------------------------------
|
|
5
|
+
# Copyright (c) 2019-2024 by Helmut Konrad Schewe. All rights reserved.
|
|
6
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
7
|
+
# use or distribution is an offensive act against international law and may
|
|
8
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
9
|
+
#==============================================================================
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import re
|
|
13
|
+
import subprocess
|
|
14
|
+
|
|
15
|
+
import setuptools
|
|
16
|
+
|
|
17
|
+
ROOT = os.path.dirname(__file__)
|
|
18
|
+
|
|
19
|
+
with open(os.path.join(ROOT, 'README'), encoding='utf8') as fp:
|
|
20
|
+
README = fp.read()
|
|
21
|
+
|
|
22
|
+
with open(os.path.join(ROOT, 'utilo/__init__.py'), encoding='utf8') as fp:
|
|
23
|
+
VERSION = re.search(r'__version__ = \'(.*?)\'', fp.read()).group(1)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def version() -> str:
|
|
27
|
+
assert VERSION, VERSION
|
|
28
|
+
completed = subprocess.run(
|
|
29
|
+
'git describe'.split(),
|
|
30
|
+
capture_output=True,
|
|
31
|
+
)
|
|
32
|
+
value: str = completed.stdout.strip().decode('utf8')
|
|
33
|
+
if value == VERSION:
|
|
34
|
+
return VERSION
|
|
35
|
+
# transform v2.40.1-5-gc1b4bee to
|
|
36
|
+
# utilo-2.93.0.post6+g3b6726a
|
|
37
|
+
value = value[1:]
|
|
38
|
+
value = value.replace('-', '.post', 1)
|
|
39
|
+
value = value.replace('-g', '+g')
|
|
40
|
+
if not value:
|
|
41
|
+
return VERSION
|
|
42
|
+
return value
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
setuptools.setup(
|
|
47
|
+
author='Helmut Konrad Schewe',
|
|
48
|
+
author_email='helmutus@outlook.com',
|
|
49
|
+
description='write it once',
|
|
50
|
+
include_package_data=True,
|
|
51
|
+
long_description=README,
|
|
52
|
+
long_description_content_type='text/markdown',
|
|
53
|
+
name='utilo',
|
|
54
|
+
platforms='any',
|
|
55
|
+
url='https://github.com/anaticulae/utilo',
|
|
56
|
+
version=version(),
|
|
57
|
+
zip_safe=False, # create 'zip'-file if True. Don't do it!
|
|
58
|
+
classifiers=[
|
|
59
|
+
'Programming Language :: Python :: 3.10',
|
|
60
|
+
'Programming Language :: Python :: 3.11',
|
|
61
|
+
'Programming Language :: Python :: 3.12',
|
|
62
|
+
'Programming Language :: Python :: 3.13',
|
|
63
|
+
'Programming Language :: Python :: 3.14',
|
|
64
|
+
],
|
|
65
|
+
packages=[
|
|
66
|
+
'utilo',
|
|
67
|
+
'utilo.classifier',
|
|
68
|
+
'utilo.cli',
|
|
69
|
+
'utilo.feature',
|
|
70
|
+
'utilo.file',
|
|
71
|
+
'utilo.math',
|
|
72
|
+
'utilo.string',
|
|
73
|
+
'utilo.xyz',
|
|
74
|
+
'utilotest',
|
|
75
|
+
],
|
|
76
|
+
entry_points={
|
|
77
|
+
'console_scripts': [
|
|
78
|
+
'utilo_lock = utilo.xyz.lock:main',
|
|
79
|
+
'utilo_unlock = utilo.xyz.lock:unlock',
|
|
80
|
+
'utilo_table = utilo.xyz.table:main',
|
|
81
|
+
'utilo_tidy = utilo.xyz.tidy:main',
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2019-2024 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
import utilo
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_collection_make_unique():
|
|
14
|
+
assert utilo.make_unique(['a', 'b', 'c', 'd', 'a']) == ['a', 'b', 'c', 'd']
|
|
15
|
+
assert utilo.make_unique([1, 2, 3, 1, 2, 3]) == [1, 2, 3]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_single_contains():
|
|
19
|
+
single = utilo.Single()
|
|
20
|
+
assert not single.contains(10)
|
|
21
|
+
assert single.contains(10)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_single_contains_unhashable():
|
|
25
|
+
"""Support unhashable items."""
|
|
26
|
+
single = utilo.Single()
|
|
27
|
+
assert not single.contains(set())
|
|
28
|
+
assert single.contains(set())
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_single_equal_hash():
|
|
32
|
+
assert hash(-2) == hash(-1)
|
|
33
|
+
|
|
34
|
+
single = utilo.Single()
|
|
35
|
+
assert not single.contains(-2)
|
|
36
|
+
assert not single.contains(-1)
|
|
37
|
+
assert single.contains(-2)
|
|
38
|
+
assert single.contains(-1)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2020-2024 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
import dataclasses
|
|
11
|
+
|
|
12
|
+
import utilo
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_simplify():
|
|
16
|
+
"""Convert object to python basic data structures."""
|
|
17
|
+
example = utilo.FeaturePackConfig()
|
|
18
|
+
simple = utilo.simplify(example)
|
|
19
|
+
assert 'prefixflag' in simple
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclasses.dataclass
|
|
23
|
+
class Human:
|
|
24
|
+
name: str = None
|
|
25
|
+
year: int = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_simplify_dataclass():
|
|
29
|
+
data = Human('Helm', 1920)
|
|
30
|
+
before = hash(str(data))
|
|
31
|
+
simple = utilo.simplify(data)
|
|
32
|
+
assert simple
|
|
33
|
+
assert hash(str(data)) == before, 'do not change data while simplify'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2019-2024 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
from utilo import current
|
|
11
|
+
from utilo import timedate
|
|
12
|
+
from utilo import today
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_today():
|
|
16
|
+
assert len(today()) == 10
|
|
17
|
+
assert today().count('.') == 2
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_current():
|
|
21
|
+
assert len(current()) == 5
|
|
22
|
+
assert current().count(':') == 1
|
|
23
|
+
|
|
24
|
+
assert len(current(True)) == 8
|
|
25
|
+
assert current(True).count(':') == 2
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_time_and_date():
|
|
29
|
+
assert ' ' in timedate()
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2022-2024 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
import utilo
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@utilo.empty_replace(member=10, glember='hello')
|
|
16
|
+
def replace_default(first=None, glember=utilo.EMPTY, member=utilo.EMPTY):
|
|
17
|
+
return first, member, glember
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_empty_replace():
|
|
21
|
+
assert replace_default('?', None) == ('?', 10, None)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_empty_replace_invalid_signature_does_not_match():
|
|
25
|
+
with pytest.raises(ValueError):
|
|
26
|
+
|
|
27
|
+
@utilo.empty_replace(tember=10, september='hello')
|
|
28
|
+
def replacce(first=None, member=utilo.EMPTY, glember=utilo.EMPTY):
|
|
29
|
+
return first, member, glember
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_empty_replace_invalid_signature_missing_default():
|
|
33
|
+
with pytest.raises(ValueError):
|
|
34
|
+
|
|
35
|
+
@utilo.empty_replace(member=1, glember=2, tember=3)
|
|
36
|
+
def replacce(first=None, member=utilo.EMPTY, glember=utilo.EMPTY):
|
|
37
|
+
return first, member, glember
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2019-2024 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
#==============================================================================
|
|
9
|
+
|
|
10
|
+
from pytest import raises
|
|
11
|
+
|
|
12
|
+
from utilo import CANCELLED_BY_USER
|
|
13
|
+
from utilo import FAILURE
|
|
14
|
+
from utilo import handle_error
|
|
15
|
+
from utilo import saveme
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_invoking_exception():
|
|
19
|
+
|
|
20
|
+
@saveme
|
|
21
|
+
def function_with_exception():
|
|
22
|
+
raise Exception() # pylint:disable=W0719
|
|
23
|
+
|
|
24
|
+
with raises(SystemExit) as exception:
|
|
25
|
+
function_with_exception()
|
|
26
|
+
|
|
27
|
+
assert exception.value.code == FAILURE
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_invoking_exception_with_argument():
|
|
31
|
+
"""Check passing decorator argument"""
|
|
32
|
+
|
|
33
|
+
@saveme(systemexit=True)
|
|
34
|
+
def function_with_exception():
|
|
35
|
+
raise Exception() # pylint:disable=W0719
|
|
36
|
+
|
|
37
|
+
with raises(SystemExit) as exception:
|
|
38
|
+
function_with_exception()
|
|
39
|
+
|
|
40
|
+
assert exception.value.code == FAILURE
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_canceling_by_user():
|
|
44
|
+
|
|
45
|
+
@saveme
|
|
46
|
+
def keyboard_interrupt():
|
|
47
|
+
raise KeyboardInterrupt
|
|
48
|
+
|
|
49
|
+
with raises(SystemExit) as exception:
|
|
50
|
+
keyboard_interrupt()
|
|
51
|
+
|
|
52
|
+
assert exception.value.code == CANCELLED_BY_USER
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_invoking_empty():
|
|
56
|
+
|
|
57
|
+
@saveme
|
|
58
|
+
def function():
|
|
59
|
+
return 2
|
|
60
|
+
|
|
61
|
+
with raises(SystemExit) as exception:
|
|
62
|
+
function()
|
|
63
|
+
assert exception.value.code == 2
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_invoking_exception_without_system_exit():
|
|
67
|
+
|
|
68
|
+
@saveme(systemexit=False)
|
|
69
|
+
def function_with_exception():
|
|
70
|
+
raise Exception() # pylint:disable=W0719
|
|
71
|
+
|
|
72
|
+
returncode = function_with_exception()
|
|
73
|
+
|
|
74
|
+
assert returncode == FAILURE
|
|
75
|
+
|
|
76
|
+
@saveme(systemexit=False)
|
|
77
|
+
def no_exception():
|
|
78
|
+
return 'Hallo'
|
|
79
|
+
|
|
80
|
+
returncode = no_exception()
|
|
81
|
+
|
|
82
|
+
assert returncode == 'Hallo'
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_error_handle_error():
|
|
86
|
+
"""Catch raised error and return specified return code `37`"""
|
|
87
|
+
with raises(SystemExit) as exception:
|
|
88
|
+
with handle_error(ValueError, code=37):
|
|
89
|
+
raise ValueError()
|
|
90
|
+
|
|
91
|
+
assert exception.value.code == 37
|