minor-utils 0.2.0.dev1__tar.gz → 0.2.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.
- minor_utils-0.2.1/PKG-INFO +49 -0
- minor_utils-0.2.1/README.md +40 -0
- {minor_utils-0.2.0.dev1 → minor_utils-0.2.1}/minor_utils/__init__.py +3 -1
- {minor_utils-0.2.0.dev1 → minor_utils-0.2.1}/minor_utils/formatter.py +56 -56
- {minor_utils-0.2.0.dev1 → minor_utils-0.2.1}/minor_utils/func_manager.py +2 -2
- minor_utils-0.2.1/minor_utils.egg-info/PKG-INFO +49 -0
- {minor_utils-0.2.0.dev1 → minor_utils-0.2.1}/minor_utils.egg-info/SOURCES.txt +1 -0
- {minor_utils-0.2.0.dev1 → minor_utils-0.2.1}/pyproject.toml +1 -1
- minor_utils-0.2.0.dev1/PKG-INFO +0 -8
- minor_utils-0.2.0.dev1/minor_utils.egg-info/PKG-INFO +0 -8
- {minor_utils-0.2.0.dev1 → minor_utils-0.2.1}/minor_utils/errors.py +0 -0
- {minor_utils-0.2.0.dev1 → minor_utils-0.2.1}/minor_utils.egg-info/dependency_links.txt +0 -0
- {minor_utils-0.2.0.dev1 → minor_utils-0.2.1}/minor_utils.egg-info/top_level.txt +0 -0
- {minor_utils-0.2.0.dev1 → minor_utils-0.2.1}/setup.cfg +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minor_utils
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Utils compilation for easier work
|
|
5
|
+
Author-email: CyberAxolotl <minor.gleb@outlook.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# minor-utils
|
|
11
|
+
|
|
12
|
+
Utility library for formatting and function management.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install minor-utils
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Modules
|
|
21
|
+
|
|
22
|
+
### Formatter
|
|
23
|
+
Format strings using built-in or custom formats. Supports pipelines, aliases, and enable/disable of formats.
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from minor_utils import Formatter
|
|
27
|
+
|
|
28
|
+
Formatter.formatting("hello world", "camelCase") # "helloWorld"
|
|
29
|
+
Formatter.pipe("Hello World", "lower", "snake_case") # "hello_world"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Manager
|
|
33
|
+
Register and manage functions with a menu-based runner.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from minor_utils import Manager
|
|
37
|
+
|
|
38
|
+
m = Manager()
|
|
39
|
+
|
|
40
|
+
@m.add_func
|
|
41
|
+
def greet():
|
|
42
|
+
print("Hello!")
|
|
43
|
+
|
|
44
|
+
m.run_manual()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Note
|
|
48
|
+
|
|
49
|
+
The project is in early development. APIs may change, bugs are possible.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# minor-utils
|
|
2
|
+
|
|
3
|
+
Utility library for formatting and function management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install minor-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Modules
|
|
12
|
+
|
|
13
|
+
### Formatter
|
|
14
|
+
Format strings using built-in or custom formats. Supports pipelines, aliases, and enable/disable of formats.
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from minor_utils import Formatter
|
|
18
|
+
|
|
19
|
+
Formatter.formatting("hello world", "camelCase") # "helloWorld"
|
|
20
|
+
Formatter.pipe("Hello World", "lower", "snake_case") # "hello_world"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Manager
|
|
24
|
+
Register and manage functions with a menu-based runner.
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from minor_utils import Manager
|
|
28
|
+
|
|
29
|
+
m = Manager()
|
|
30
|
+
|
|
31
|
+
@m.add_func
|
|
32
|
+
def greet():
|
|
33
|
+
print("Hello!")
|
|
34
|
+
|
|
35
|
+
m.run_manual()
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Note
|
|
39
|
+
|
|
40
|
+
The project is in early development. APIs may change, bugs are possible.
|
|
@@ -71,8 +71,8 @@ class Formatter:
|
|
|
71
71
|
|
|
72
72
|
formats = {
|
|
73
73
|
"capitalize": cap,
|
|
74
|
-
"
|
|
75
|
-
"
|
|
74
|
+
"upper": up,
|
|
75
|
+
"lower": down,
|
|
76
76
|
"spike": spike,
|
|
77
77
|
"clean": clean,
|
|
78
78
|
"camelCase": camel_case,
|
|
@@ -87,7 +87,7 @@ class Formatter:
|
|
|
87
87
|
format_aliases = {}
|
|
88
88
|
enabled_formats = list(formats.keys()) + list(format_aliases.keys())
|
|
89
89
|
|
|
90
|
-
#--------(
|
|
90
|
+
#--------(Formating API)--------
|
|
91
91
|
@classmethod
|
|
92
92
|
def get_callable(cls, string_format):
|
|
93
93
|
if string_format in cls.format_aliases:
|
|
@@ -307,6 +307,52 @@ class Formatter:
|
|
|
307
307
|
#--------
|
|
308
308
|
|
|
309
309
|
#--------
|
|
310
|
+
@classmethod
|
|
311
|
+
def rename_format(cls, old_name, new_name):
|
|
312
|
+
if not cls.is_existing_format(old_name):
|
|
313
|
+
raise InvalidArgumentError(
|
|
314
|
+
f"Unable to rename format: format '{old_name}' does not exist."
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
if cls.is_existing_format(new_name):
|
|
318
|
+
raise FormatAlreadyExistsError(
|
|
319
|
+
f"Unable to rename format: format '{new_name}' already exists."
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
if cls.is_existing_alias(new_name):
|
|
323
|
+
raise FormatAlreadyExistsError(
|
|
324
|
+
f"Unable to rename format: alias '{new_name}' already exists."
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
if new_name in cls.default_formats:
|
|
328
|
+
raise DefaultFormatModificationError(
|
|
329
|
+
f"Unable to replace format: '{new_name}' is a default format."
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
aliases = list(cls.aliases_of(old_name))
|
|
333
|
+
|
|
334
|
+
func = cls.formats.pop(old_name)
|
|
335
|
+
|
|
336
|
+
cls.formats[new_name] = func
|
|
337
|
+
|
|
338
|
+
if old_name in cls.custom_formats:
|
|
339
|
+
cls.custom_formats[new_name] = cls.custom_formats.pop(old_name)
|
|
340
|
+
|
|
341
|
+
if old_name in cls.enabled_formats:
|
|
342
|
+
cls.enabled_formats.remove(old_name)
|
|
343
|
+
cls.enabled_formats.append(new_name)
|
|
344
|
+
|
|
345
|
+
for alias in aliases:
|
|
346
|
+
cls.format_aliases[alias] = func
|
|
347
|
+
#--------
|
|
348
|
+
|
|
349
|
+
#--------
|
|
350
|
+
@classmethod
|
|
351
|
+
def has_format(cls, name):
|
|
352
|
+
return cls.is_existing_format(name)
|
|
353
|
+
#--------
|
|
354
|
+
|
|
355
|
+
#--------(Getters API)--------
|
|
310
356
|
@classmethod
|
|
311
357
|
def get_formats(cls):
|
|
312
358
|
return cls.formats
|
|
@@ -382,59 +428,7 @@ class Formatter:
|
|
|
382
428
|
return cls.get_format_function(name).__doc__
|
|
383
429
|
#--------
|
|
384
430
|
|
|
385
|
-
#--------
|
|
386
|
-
@classmethod
|
|
387
|
-
def rename_format(cls, old_name, new_name):
|
|
388
|
-
if not cls.is_existing_format(old_name):
|
|
389
|
-
raise InvalidArgumentError(
|
|
390
|
-
f"Unable to rename format: format '{old_name}' does not exist."
|
|
391
|
-
)
|
|
392
|
-
|
|
393
|
-
if cls.is_existing_format(new_name):
|
|
394
|
-
raise FormatAlreadyExistsError(
|
|
395
|
-
f"Unable to rename format: format '{new_name}' already exists."
|
|
396
|
-
)
|
|
397
|
-
|
|
398
|
-
if cls.is_existing_alias(new_name):
|
|
399
|
-
raise FormatAlreadyExistsError(
|
|
400
|
-
f"Unable to rename format: alias '{new_name}' already exists."
|
|
401
|
-
)
|
|
402
|
-
|
|
403
|
-
if new_name in cls.default_formats:
|
|
404
|
-
raise DefaultFormatModificationError(
|
|
405
|
-
f"Unable to replace format: '{new_name}' is a default format."
|
|
406
|
-
)
|
|
407
|
-
|
|
408
|
-
aliases = list(cls.aliases_of(old_name))
|
|
409
|
-
|
|
410
|
-
func = cls.formats.pop(old_name)
|
|
411
|
-
|
|
412
|
-
cls.formats[new_name] = func
|
|
413
|
-
|
|
414
|
-
if old_name in cls.custom_formats:
|
|
415
|
-
cls.custom_formats[new_name] = cls.custom_formats.pop(old_name)
|
|
416
|
-
|
|
417
|
-
if old_name in cls.enabled_formats:
|
|
418
|
-
cls.enabled_formats.remove(old_name)
|
|
419
|
-
cls.enabled_formats.append(new_name)
|
|
420
|
-
|
|
421
|
-
for alias in aliases:
|
|
422
|
-
cls.format_aliases[alias] = func
|
|
423
|
-
#--------
|
|
424
|
-
|
|
425
|
-
#--------
|
|
426
|
-
@classmethod
|
|
427
|
-
def has_format(cls, name):
|
|
428
|
-
return cls.is_existing_format(name)
|
|
429
|
-
#--------
|
|
430
|
-
|
|
431
|
-
#--------
|
|
432
|
-
@classmethod
|
|
433
|
-
def has_alias(cls, name):
|
|
434
|
-
return cls.is_existing_alias(name)
|
|
435
|
-
#--------
|
|
436
|
-
|
|
437
|
-
#--------
|
|
431
|
+
#--------(Toggle API)--------
|
|
438
432
|
@classmethod
|
|
439
433
|
def disable(cls, name):
|
|
440
434
|
if not cls.is_existing_format(name):
|
|
@@ -618,4 +612,10 @@ class Formatter:
|
|
|
618
612
|
@classmethod
|
|
619
613
|
def get_all_aliases(cls):
|
|
620
614
|
return cls.format_aliases
|
|
615
|
+
#--------
|
|
616
|
+
|
|
617
|
+
#--------
|
|
618
|
+
@classmethod
|
|
619
|
+
def has_alias(cls, name):
|
|
620
|
+
return cls.is_existing_alias(name)
|
|
621
621
|
#--------
|
|
@@ -38,7 +38,7 @@ class Manager:
|
|
|
38
38
|
if self.is_existing_func(func_name):
|
|
39
39
|
raise InvalidArgumentError(f"Function '{func_name}' already exists in manager {self.__name}.")
|
|
40
40
|
|
|
41
|
-
self.__funcs.append(func_name, f)
|
|
41
|
+
self.__funcs.append((func_name, f))
|
|
42
42
|
|
|
43
43
|
return f
|
|
44
44
|
|
|
@@ -278,7 +278,7 @@ class Manager:
|
|
|
278
278
|
results.setdefault(func_id, []).append(result)
|
|
279
279
|
#--------
|
|
280
280
|
|
|
281
|
-
|
|
281
|
+
#--------(Validation API)--------
|
|
282
282
|
def is_existing_func(self, name):
|
|
283
283
|
try:
|
|
284
284
|
func_id = int(name)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minor_utils
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Utils compilation for easier work
|
|
5
|
+
Author-email: CyberAxolotl <minor.gleb@outlook.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# minor-utils
|
|
11
|
+
|
|
12
|
+
Utility library for formatting and function management.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install minor-utils
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Modules
|
|
21
|
+
|
|
22
|
+
### Formatter
|
|
23
|
+
Format strings using built-in or custom formats. Supports pipelines, aliases, and enable/disable of formats.
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from minor_utils import Formatter
|
|
27
|
+
|
|
28
|
+
Formatter.formatting("hello world", "camelCase") # "helloWorld"
|
|
29
|
+
Formatter.pipe("Hello World", "lower", "snake_case") # "hello_world"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Manager
|
|
33
|
+
Register and manage functions with a menu-based runner.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from minor_utils import Manager
|
|
37
|
+
|
|
38
|
+
m = Manager()
|
|
39
|
+
|
|
40
|
+
@m.add_func
|
|
41
|
+
def greet():
|
|
42
|
+
print("Hello!")
|
|
43
|
+
|
|
44
|
+
m.run_manual()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Note
|
|
48
|
+
|
|
49
|
+
The project is in early development. APIs may change, bugs are possible.
|
minor_utils-0.2.0.dev1/PKG-INFO
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|