vt-commons 0.0.1__py3-none-any.whl → 0.0.1.dev2__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.
- {vt_commons-0.0.1.dist-info → vt_commons-0.0.1.dev2.dist-info}/METADATA +50 -39
- {vt_commons-0.0.1.dist-info → vt_commons-0.0.1.dev2.dist-info}/RECORD +5 -5
- {vt_commons-0.0.1.dist-info → vt_commons-0.0.1.dev2.dist-info}/WHEEL +0 -0
- {vt_commons-0.0.1.dist-info → vt_commons-0.0.1.dev2.dist-info}/licenses/LICENSE +0 -0
- {vt_commons-0.0.1.dist-info → vt_commons-0.0.1.dev2.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: vt-commons
|
3
|
-
Version: 0.0.1
|
3
|
+
Version: 0.0.1.dev2
|
4
4
|
Summary: Reusable common utilities, interfaces and implementations for python projects.
|
5
5
|
Author-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
|
6
6
|
Maintainer-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
|
@@ -28,79 +28,90 @@ Dynamic: license-file
|
|
28
28
|
|
29
29
|
# vt-commons
|
30
30
|
|
31
|
+

|
32
|
+

|
31
33
|
[](https://github.com/Vaastav-Technologies/py-commons/actions/workflows/test.yml)
|
32
34
|
[](https://github.com/Vaastav-Technologies/py-commons/actions/workflows/typecheck.yml)
|
33
35
|
[](https://github.com/Vaastav-Technologies/py-commons/actions/workflows/lint.yml)
|
34
36
|
[](https://codecov.io/gh/Vaastav-Technologies/py-commons)
|
35
37
|
[](https://github.com/Vaastav-Technologies/py-commons/actions/workflows/python-publish.yml)
|
38
|
+

|
36
39
|
|
37
40
|
---
|
38
|
-
|
41
|
+
A fully typed library for commons methods, utils, interfaces and implementations for python projects.
|
39
42
|
|
40
43
|
### Install
|
41
44
|
|
42
|
-
```shell
|
43
|
-
pip install vt-commons
|
44
|
-
```
|
45
|
+
```shell
|
46
|
+
pip install vt-commons
|
47
|
+
```
|
45
48
|
|
46
49
|
#### Usage examples
|
47
50
|
|
48
51
|
- Check for OS
|
49
52
|
```python
|
50
|
-
|
53
|
+
from vt.utils.commons.commons.os import is_windows
|
51
54
|
|
52
|
-
|
55
|
+
windows = is_windows()
|
53
56
|
```
|
54
57
|
Check in `vt.utils.commons.commons.os` and documentation for more functions and utilities related to OS.
|
58
|
+
|
59
|
+
|
55
60
|
- Perform some operation on a root directory
|
56
61
|
```python
|
57
|
-
|
58
|
-
|
62
|
+
from vt.utils.commons.commons.op import RootDirOp, CWDRootDirOp, RootDirOps
|
63
|
+
from pathlib import Path
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
+
class MyRootDirectoryOperation(RootDirOp):
|
66
|
+
...
|
67
|
+
@property
|
68
|
+
def root_dir(self)-> Path:
|
69
|
+
return Path('path', 'to', 'my', 'root-directory')
|
65
70
|
|
66
|
-
|
71
|
+
certain_root_dir_operation: CWDRootDirOp = RootDirOps.from_path(Path('path', 'to', 'my', 'root-directory'))
|
67
72
|
```
|
68
73
|
Check in `vt.utils.commons.commons.op` and documentation for more functions and utilities related to operations.
|
74
|
+
|
75
|
+
|
69
76
|
- Perform state operations
|
70
77
|
```python
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
78
|
+
from vt.utils.commons.commons.state import DoneMarker
|
79
|
+
|
80
|
+
# Track state by marking done
|
81
|
+
class MyStateManager(DoneMarker[int]):
|
82
|
+
def __init__(self, *args, **kwargs):
|
83
|
+
self.id_state = {1: False}
|
84
|
+
...
|
85
|
+
|
86
|
+
def mark_done(self, _id: int)-> bool:
|
87
|
+
# mark done for _id
|
88
|
+
if self.id_state[_id] is True:
|
89
|
+
return False
|
90
|
+
self.id_state[_id] = True
|
91
|
+
return True
|
85
92
|
```
|
86
93
|
Check in `vt.utils.commons.commons.state` and documentation for more functions and utilities related to tracking state.
|
94
|
+
|
95
|
+
|
87
96
|
- Check if a value is `MISSING`
|
88
97
|
```python
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
98
|
+
from vt.utils.commons.commons.core_py import MISSING, Missing, is_missing
|
99
|
+
|
100
|
+
def some_operation(arg: Missing = MISSING):
|
101
|
+
"""
|
102
|
+
``MISSING`` can be used as a default value sentinel when ``None`` is a valid value for arg.
|
103
|
+
"""
|
104
|
+
arg = 10 if is_missing(arg) else arg
|
105
|
+
...
|
97
106
|
```
|
98
107
|
Check in `vt.utils.commons.commons.core_py` and documentation for more functions and utilities related to function management.
|
108
|
+
|
109
|
+
|
99
110
|
- Query and operate on iterables
|
100
111
|
```python
|
101
|
-
|
112
|
+
from vt.utils.commons.commons.collections import get_first_true
|
102
113
|
|
103
|
-
|
114
|
+
assert 3 == get_first_true([1, 3, 5, 7, 2, 1], 8, lambda x: x>2)
|
104
115
|
```
|
105
116
|
Check in `vt.utils.commons.commons.collections` and documentation for more functions and utilities related to collection management.
|
106
117
|
|
@@ -15,8 +15,8 @@ vt/utils/commons/commons/os/posix.py,sha256=V8kij7pGDXj6uJWWf4gUhjzYlBMDMKvWqcVJ
|
|
15
15
|
vt/utils/commons/commons/os/windows.py,sha256=fJeVn0cdNplzPOiJbeGY8yyriug28Jei1WGKaLBFJFw,671
|
16
16
|
vt/utils/commons/commons/state/__init__.py,sha256=sKFo9_VSnv_VyFlnzUnET7_QkKnqXYrj9cEU1u3w83I,494
|
17
17
|
vt/utils/commons/commons/state/done.py,sha256=fGs0yNWgwRwm44gzmR6FNX7NKq7-39rEnsri9ztyZ4o,5146
|
18
|
-
vt_commons-0.0.1.dist-info/licenses/LICENSE,sha256=pOzr5bMWS6mHi3vro8d5vw0qW1i14rVq2XFrDuystVY,11372
|
19
|
-
vt_commons-0.0.1.dist-info/METADATA,sha256=
|
20
|
-
vt_commons-0.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
-
vt_commons-0.0.1.dist-info/top_level.txt,sha256=aN5KWgJq84W0MDifCX3yRJAp04FH7pd5PDh7qa2P8sM,3
|
22
|
-
vt_commons-0.0.1.dist-info/RECORD,,
|
18
|
+
vt_commons-0.0.1.dev2.dist-info/licenses/LICENSE,sha256=pOzr5bMWS6mHi3vro8d5vw0qW1i14rVq2XFrDuystVY,11372
|
19
|
+
vt_commons-0.0.1.dev2.dist-info/METADATA,sha256=DXogsZHGAJw64-4BAxF3YwoIPCdlUcrYcT-XbvBfIBU,4924
|
20
|
+
vt_commons-0.0.1.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
vt_commons-0.0.1.dev2.dist-info/top_level.txt,sha256=aN5KWgJq84W0MDifCX3yRJAp04FH7pd5PDh7qa2P8sM,3
|
22
|
+
vt_commons-0.0.1.dev2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|