untils 1.0.0__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.
- untils-1.0.0/PKG-INFO +73 -0
- untils-1.0.0/README.md +50 -0
- untils-1.0.0/pyproject.toml +35 -0
- untils-1.0.0/setup.cfg +4 -0
- untils-1.0.0/src/untils/__init__.py +28 -0
- untils-1.0.0/src/untils/command.py +130 -0
- untils-1.0.0/src/untils/command_system.py +403 -0
- untils-1.0.0/src/untils/commands_config.py +23 -0
- untils-1.0.0/src/untils/config_validator.py +616 -0
- untils-1.0.0/src/untils/factories.py +40 -0
- untils-1.0.0/src/untils/input_token.py +104 -0
- untils-1.0.0/src/untils/input_validator.py +556 -0
- untils-1.0.0/src/untils/ioreader.py +55 -0
- untils-1.0.0/src/untils/iovalidator.py +55 -0
- untils-1.0.0/src/untils/parser.py +138 -0
- untils-1.0.0/src/untils/processor.py +88 -0
- untils-1.0.0/src/untils/settings.py +114 -0
- untils-1.0.0/src/untils/tokenizer.py +108 -0
- untils-1.0.0/src/untils/utils/__init__.py +22 -0
- untils-1.0.0/src/untils/utils/constants.py +267 -0
- untils-1.0.0/src/untils/utils/decorators.py +47 -0
- untils-1.0.0/src/untils/utils/enums.py +48 -0
- untils-1.0.0/src/untils/utils/lib_warnings.py +43 -0
- untils-1.0.0/src/untils/utils/protocols.py +42 -0
- untils-1.0.0/src/untils/utils/type_aliases.py +88 -0
- untils-1.0.0/src/untils.egg-info/PKG-INFO +73 -0
- untils-1.0.0/src/untils.egg-info/SOURCES.txt +28 -0
- untils-1.0.0/src/untils.egg-info/dependency_links.txt +1 -0
- untils-1.0.0/src/untils.egg-info/requires.txt +7 -0
- untils-1.0.0/src/untils.egg-info/top_level.txt +1 -0
untils-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: untils
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Light-weight library for console games or small utils to process user input as commands and describe structure with config.
|
|
5
|
+
Author: BesBobowyy
|
|
6
|
+
Project-URL: GitHub, https://github.com/BesBobowyy/untils
|
|
7
|
+
Keywords: cli,console,lightweight
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Requires-Python: >=3.12
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: README.md
|
|
17
|
+
Provides-Extra: test
|
|
18
|
+
Requires-Dist: pytest>=9.0.0; extra == "test"
|
|
19
|
+
Provides-Extra: docs
|
|
20
|
+
Requires-Dist: mkdocs>=1.6.0; extra == "docs"
|
|
21
|
+
Requires-Dist: mkdocs-material; extra == "docs"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# Welcome to `untils`
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
*untils* - Is light-weight library for console games or small utils to process user input as commands and describe structure with config.
|
|
31
|
+
|
|
32
|
+
## Abilities
|
|
33
|
+
|
|
34
|
+
- Module-based config in markup line.
|
|
35
|
+
- Custom logic in OOP.
|
|
36
|
+
- Validation and parsing user input for 10 lines.
|
|
37
|
+
- Process exceptions.
|
|
38
|
+
- Almost-perfect detailed annotations everywhere.
|
|
39
|
+
- Fast command processing (~208µs).
|
|
40
|
+
- Infinitely extendable abilities.
|
|
41
|
+
- Calm about anything.
|
|
42
|
+
|
|
43
|
+
## Architecture
|
|
44
|
+
|
|
45
|
+
This library was builded with next architecture:
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install untils
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
[Start Course](start-guide/01-first-project.md "Beginner course into the library.")
|
|
58
|
+
|
|
59
|
+
[API Reference](api-reference.md)
|
|
60
|
+
|
|
61
|
+
## Roadmap
|
|
62
|
+
|
|
63
|
+
I have resolve my thoughs to several categories:
|
|
64
|
+
|
|
65
|
+
1. **Main**:
|
|
66
|
+
- [ ] Add command description in `"description"` field.
|
|
67
|
+
- [ ] Add reserved commands in format like internal state name: `"__help__"` - Get all and available commands.
|
|
68
|
+
|
|
69
|
+
2. **Additional**:
|
|
70
|
+
- [ ] ...
|
|
71
|
+
|
|
72
|
+
3. **Conceptions**:
|
|
73
|
+
- [ ] Typing system in config through `"type"` field.
|
untils-1.0.0/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Welcome to `untils`
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
*untils* - Is light-weight library for console games or small utils to process user input as commands and describe structure with config.
|
|
8
|
+
|
|
9
|
+
## Abilities
|
|
10
|
+
|
|
11
|
+
- Module-based config in markup line.
|
|
12
|
+
- Custom logic in OOP.
|
|
13
|
+
- Validation and parsing user input for 10 lines.
|
|
14
|
+
- Process exceptions.
|
|
15
|
+
- Almost-perfect detailed annotations everywhere.
|
|
16
|
+
- Fast command processing (~208µs).
|
|
17
|
+
- Infinitely extendable abilities.
|
|
18
|
+
- Calm about anything.
|
|
19
|
+
|
|
20
|
+
## Architecture
|
|
21
|
+
|
|
22
|
+
This library was builded with next architecture:
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install untils
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
[Start Course](start-guide/01-first-project.md "Beginner course into the library.")
|
|
35
|
+
|
|
36
|
+
[API Reference](api-reference.md)
|
|
37
|
+
|
|
38
|
+
## Roadmap
|
|
39
|
+
|
|
40
|
+
I have resolve my thoughs to several categories:
|
|
41
|
+
|
|
42
|
+
1. **Main**:
|
|
43
|
+
- [ ] Add command description in `"description"` field.
|
|
44
|
+
- [ ] Add reserved commands in format like internal state name: `"__help__"` - Get all and available commands.
|
|
45
|
+
|
|
46
|
+
2. **Additional**:
|
|
47
|
+
- [ ] ...
|
|
48
|
+
|
|
49
|
+
3. **Conceptions**:
|
|
50
|
+
- [ ] Typing system in config through `"type"` field.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0.3"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "untils"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
authors = [{name = "BesBobowyy"}]
|
|
9
|
+
description = "Light-weight library for console games or small utils to process user input as commands and describe structure with config."
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license-files = ["README.md"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 5 - Production/Stable",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Programming Language :: Python :: 3.14"
|
|
19
|
+
]
|
|
20
|
+
requires-python = ">=3.12"
|
|
21
|
+
keywords = ["cli", "console", "lightweight"]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
test = ["pytest>=9.0.0"]
|
|
25
|
+
docs = ["mkdocs>=1.6.0", "mkdocs-material"]
|
|
26
|
+
|
|
27
|
+
[tool.pytest]
|
|
28
|
+
minversion = "9.0"
|
|
29
|
+
addopts = ["-v"]
|
|
30
|
+
testpaths = [
|
|
31
|
+
"tests",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
GitHub = "https://github.com/BesBobowyy/untils"
|
untils-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""*untils* - Is light-weight library for console games or small utils to process user input as commands and describe structure with config."""
|
|
2
|
+
|
|
3
|
+
# pyright: reportUnusedImport=false
|
|
4
|
+
# ^^^^^^^ (Public imports.)
|
|
5
|
+
|
|
6
|
+
from untils import utils
|
|
7
|
+
|
|
8
|
+
from untils.command_system import CommandSystem
|
|
9
|
+
from untils.command import (
|
|
10
|
+
AliasNode, CommandNode, CommandWordNode, CommandFallbackNode, CommandFlagNode,
|
|
11
|
+
CommandOptionNode, StateNode
|
|
12
|
+
)
|
|
13
|
+
from untils.commands_config import CommandsConfig
|
|
14
|
+
from untils.config_validator import ConfigValidator
|
|
15
|
+
from untils.factories import CommandNodeFactory
|
|
16
|
+
from untils.input_token import (
|
|
17
|
+
RawInputToken, FinalInputTokenWord, FinalInputTokenFlag, FinalInputTokenOption
|
|
18
|
+
)
|
|
19
|
+
from untils.input_validator import InputValidator, ParsedInputValidator
|
|
20
|
+
from untils.ioreader import IOReader
|
|
21
|
+
from untils.iovalidator import IOValidator
|
|
22
|
+
from untils.parser import Parser
|
|
23
|
+
from untils.processor import Processor
|
|
24
|
+
from untils.settings import Settings
|
|
25
|
+
from untils.tokenizer import Tokenizer
|
|
26
|
+
|
|
27
|
+
__version__ = "1.0.0"
|
|
28
|
+
__author__ = "BesBobowyy"
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""command.py - Command nodes."""
|
|
2
|
+
|
|
3
|
+
from typing import List, Any
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from untils.utils.type_aliases import CommandType
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True)
|
|
10
|
+
class AliasNode():
|
|
11
|
+
"""Command alias name container."""
|
|
12
|
+
|
|
13
|
+
original_name: str
|
|
14
|
+
"""Original command name."""
|
|
15
|
+
alias_name: str
|
|
16
|
+
"""Alias name."""
|
|
17
|
+
|
|
18
|
+
def __str__(self) -> str:
|
|
19
|
+
return f"AliasNode('{self.original_name}' -> '{self.alias_name}')"
|
|
20
|
+
|
|
21
|
+
def __eq__(self, value: object) -> bool:
|
|
22
|
+
if isinstance(value, AliasNode):
|
|
23
|
+
return self.original_name == value.original_name and self.alias_name == value.alias_name
|
|
24
|
+
if isinstance(value, CommandNode):
|
|
25
|
+
if value.type == "fallback":
|
|
26
|
+
return False
|
|
27
|
+
return self.original_name == value.name
|
|
28
|
+
if isinstance(value, str):
|
|
29
|
+
return self.original_name == value and self.alias_name == value
|
|
30
|
+
return False
|
|
31
|
+
|
|
32
|
+
def __ne__(self, value: object) -> bool:
|
|
33
|
+
if isinstance(value, AliasNode):
|
|
34
|
+
return self.original_name != value.original_name or self.alias_name != value.alias_name
|
|
35
|
+
if isinstance(value, CommandNode):
|
|
36
|
+
if value.type == "fallback":
|
|
37
|
+
return True
|
|
38
|
+
return self.original_name != value.name
|
|
39
|
+
if isinstance(value, str):
|
|
40
|
+
return self.original_name != value or self.alias_name != value
|
|
41
|
+
return True
|
|
42
|
+
|
|
43
|
+
@dataclass(frozen=True)
|
|
44
|
+
class CommandNode:
|
|
45
|
+
"""Universal template for command nodes."""
|
|
46
|
+
|
|
47
|
+
name: str
|
|
48
|
+
"""Command name."""
|
|
49
|
+
type: CommandType
|
|
50
|
+
"""Command type."""
|
|
51
|
+
|
|
52
|
+
def __eq__(self, value: object) -> bool:
|
|
53
|
+
if isinstance(value, CommandNode):
|
|
54
|
+
return self.name == value.name and self.type == value.type
|
|
55
|
+
if isinstance(value, str):
|
|
56
|
+
if self.type != "fallback":
|
|
57
|
+
return self.name == value
|
|
58
|
+
return True
|
|
59
|
+
return False
|
|
60
|
+
|
|
61
|
+
def __ne__(self, value: object) -> bool:
|
|
62
|
+
if isinstance(value, CommandNode):
|
|
63
|
+
return self.name != value.name or self.type != value.type
|
|
64
|
+
if isinstance(value, str):
|
|
65
|
+
if self.type != "fallback":
|
|
66
|
+
return self.name != value
|
|
67
|
+
return False
|
|
68
|
+
return True
|
|
69
|
+
|
|
70
|
+
@dataclass(frozen=True)
|
|
71
|
+
class CommandWordNode(CommandNode):
|
|
72
|
+
"""The word command type."""
|
|
73
|
+
|
|
74
|
+
aliases: List[AliasNode]
|
|
75
|
+
"""Command aliases."""
|
|
76
|
+
children: List[CommandNode]
|
|
77
|
+
"""Next commands below this."""
|
|
78
|
+
|
|
79
|
+
def __str__(self) -> str:
|
|
80
|
+
return f"CommandWordNode[{self.name} : {self.aliases}]{self.children}"
|
|
81
|
+
|
|
82
|
+
@dataclass(frozen=True)
|
|
83
|
+
class CommandFallbackNode(CommandNode):
|
|
84
|
+
"""Command node for fallback type."""
|
|
85
|
+
|
|
86
|
+
default: str
|
|
87
|
+
"""A default value."""
|
|
88
|
+
children: List[CommandNode]
|
|
89
|
+
"""Next commands below this."""
|
|
90
|
+
|
|
91
|
+
def __str__(self) -> str:
|
|
92
|
+
return f"CommandFallbackNode[{self.name}](default='{self.default}'){self.children}"
|
|
93
|
+
|
|
94
|
+
@dataclass(frozen=True)
|
|
95
|
+
class CommandFlagNode(CommandNode):
|
|
96
|
+
"""Command node for flag type."""
|
|
97
|
+
|
|
98
|
+
aliases: List[AliasNode]
|
|
99
|
+
"""Command aliases."""
|
|
100
|
+
default: Any
|
|
101
|
+
"""A default value."""
|
|
102
|
+
|
|
103
|
+
def __str__(self) -> str:
|
|
104
|
+
return f"CommandFlagNode[{self.name} : {self.aliases}](default={repr(self.default)})"
|
|
105
|
+
|
|
106
|
+
@dataclass(frozen=True)
|
|
107
|
+
class CommandOptionNode(CommandNode):
|
|
108
|
+
"""Command node for option type."""
|
|
109
|
+
|
|
110
|
+
aliases: List[AliasNode]
|
|
111
|
+
"""Command aliases."""
|
|
112
|
+
default: Any
|
|
113
|
+
"""A default value."""
|
|
114
|
+
|
|
115
|
+
def __str__(self) -> str:
|
|
116
|
+
return f"CommandOptionNode[{self.name} : {self.aliases}](default={repr(self.default)})"
|
|
117
|
+
|
|
118
|
+
@dataclass(frozen=True)
|
|
119
|
+
class StateNode:
|
|
120
|
+
"""A state node in config."""
|
|
121
|
+
|
|
122
|
+
name: str
|
|
123
|
+
"""The state name."""
|
|
124
|
+
is_internal: bool
|
|
125
|
+
"""Is internal state, which typed in the format `__{name}__`."""
|
|
126
|
+
commands: List[str]
|
|
127
|
+
"""Allowed commands by this state."""
|
|
128
|
+
|
|
129
|
+
def __str__(self) -> str:
|
|
130
|
+
return f"StateNode[{'!' if self.is_internal else ''}{self.name}]{self.commands}"
|