tuk-string 0.1.0.2026061400__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.
@@ -0,0 +1,38 @@
1
+ name: Publish Python Package to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ deploy:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+
13
+ - name: Set up Python
14
+ uses: actions/setup-python@v4
15
+ with:
16
+ python-version: '3.11'
17
+
18
+ - name: Install build tools
19
+ run: |
20
+ python -m pip install --upgrade setuptools setuptools_scm
21
+ python -m pip install --upgrade wheel
22
+ python -m pip install --upgrade twine
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ python -m pip install -r requirements.txt
28
+
29
+ - name: Build package
30
+ run: |
31
+ python setup.py sdist bdist_wheel
32
+ twine check dist/*
33
+
34
+ - name: Publish package
35
+ env:
36
+ TWINE_USERNAME: __token__
37
+ TWINE_PASSWORD: ${{ secrets.PYPI_PROJTOKEN }}
38
+ run: twine upload --verbose dist/*
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ .idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tarcadia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: tuk-string
3
+ Version: 0.1.0.2026061400
4
+ Summary: TUK string Package
5
+ Home-page: https://github.com/Tarcadia/tuk-string
6
+ Author: Tarcadia
7
+ Author-email: dont@email.me
8
+ License: MIT
9
+ Project-URL: Bug Reports, https://github.com/Tarcadia/tuk-string/issues
10
+ Project-URL: Source, https://github.com/Tarcadia/tuk-string
11
+ Keywords: string,placeholder,selector,tuk
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: keywords
27
+ Dynamic: license
28
+ Dynamic: license-file
29
+ Dynamic: project-url
30
+ Dynamic: requires-python
31
+ Dynamic: summary
32
+
33
+ # tuk-string
@@ -0,0 +1 @@
1
+ # tuk-string
File without changes
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+
4
+ import sys
5
+ import setuptools
6
+ from pathlib import Path
7
+ from importlib import import_module
8
+
9
+ PKG = "tuk.string"
10
+ NAME = "tuk-string"
11
+ DESCRIPTION = "TUK string Package"
12
+ KEYWORDS = ["string", "placeholder", "selector", "tuk"]
13
+
14
+ CSD = Path(__file__).parent.resolve()
15
+ PATH_SRC = CSD / "src"
16
+ PATH_DOC = CSD / "doc"
17
+ PATH_TEST = CSD / "test"
18
+ PATH_REQUIREMENTS = CSD / "requirements.txt"
19
+ PATH_LICENSE = CSD / "LICENSE"
20
+ PATH_README = CSD / "README.md"
21
+
22
+
23
+ sys.path.insert(0, PATH_SRC.as_posix())
24
+ pkg = import_module(PKG)
25
+
26
+
27
+
28
+ def _get_requirements():
29
+ if not PATH_REQUIREMENTS.exists():
30
+ return []
31
+ with open(PATH_REQUIREMENTS, encoding='utf-8') as f:
32
+ return [line.strip() for line in f if line.strip() and not line.startswith('#')]
33
+
34
+ def _get_long_description():
35
+ if not PATH_README.exists():
36
+ return ""
37
+ with open(PATH_README, encoding='utf-8') as f:
38
+ return f.read()
39
+
40
+ def _get_version():
41
+ try:
42
+ from setuptools_scm import get_version
43
+ return get_version(root=CSD)
44
+ except ImportError:
45
+ return pkg.__version__
46
+
47
+
48
+
49
+ setuptools.setup(
50
+ name=NAME,
51
+ description=DESCRIPTION,
52
+ long_description=_get_long_description(),
53
+ long_description_content_type="text/markdown",
54
+ version=_get_version(),
55
+ license=pkg.__license__,
56
+ author=pkg.__author__,
57
+ author_email="dont@email.me",
58
+ url=pkg.__url__,
59
+ project_urls={
60
+ "Bug Reports": pkg.__url__ + "/issues",
61
+ "Source": pkg.__url__,
62
+ },
63
+ package_dir={"": PATH_SRC.as_posix()},
64
+ packages=setuptools.find_namespace_packages(where=PATH_SRC.as_posix()),
65
+ python_requires=">=3.11",
66
+ setup_requires=["setuptools_scm>=6.0"],
67
+ install_requires=_get_requirements(),
68
+ keywords=KEYWORDS,
69
+ classifiers=[
70
+ "Development Status :: 2 - Pre-Alpha",
71
+ "Intended Audience :: Developers",
72
+ "Programming Language :: Python :: 3.11",
73
+ "Operating System :: OS Independent",
74
+ "Typing :: Typed",
75
+ ]
76
+ )
77
+
@@ -0,0 +1,11 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+
4
+ __author__ = "Tarcadia"
5
+ __url__ = "https://github.com/Tarcadia/tuk-string"
6
+ __copyright__ = "Copyright 2025"
7
+ __credits__ = ["Tarcadia"]
8
+ __license__ = "MIT"
9
+ __version__ = "0.1.0"
10
+
11
+
@@ -0,0 +1,44 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ import string
4
+ import re
5
+
6
+
7
+ class Identifier(str):
8
+
9
+ CHARSET = string.ascii_letters + string.digits + r"_"
10
+ PATTERN = r"[a-zA-Z_][a-zA-Z0-9_]*"
11
+
12
+ @classmethod
13
+ def validate(cls, value:str) -> bool:
14
+ _validate = True
15
+ if cls.CHARSET is not None:
16
+ _validate &= all(c in cls.CHARSET for c in value)
17
+ if cls.PATTERN is not None:
18
+ _validate &= re.match(rf"^{cls.PATTERN}$", value) is not None
19
+ return _validate
20
+
21
+ def __new__(cls, value):
22
+ value = str(value)
23
+ if not cls.validate(value):
24
+ raise ValueError(f"Invalid identifier: {value}")
25
+ return super().__new__(cls, value)
26
+
27
+
28
+ class IdentifierLower(Identifier):
29
+
30
+ CHARSET = string.ascii_lowercase + string.digits + r"_"
31
+
32
+ def __new__(cls, value):
33
+ value = str(value).lower()
34
+ return super().__new__(cls, value)
35
+
36
+
37
+ class IdentifierUpper(Identifier):
38
+
39
+ CHARSET = string.ascii_uppercase + string.digits + r"_"
40
+
41
+ def __new__(cls, value):
42
+ value = str(value).upper()
43
+ return super().__new__(cls, value)
44
+
@@ -0,0 +1,79 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ import string
4
+ import re
5
+
6
+ from .identifier import Identifier
7
+
8
+
9
+ def Placeholder(icls, vcls):
10
+
11
+ if not issubclass(icls, Identifier):
12
+ raise TypeError("Placeholder can only be applied to subclasses of Identifier.")
13
+
14
+ if not issubclass(vcls, Identifier):
15
+ raise TypeError("Placeholder value can only be subclasses of Identifier.")
16
+
17
+ _PREFIX = r"${"
18
+ _SUFFIX = r"}"
19
+
20
+ if icls.PATTERN is None:
21
+ _IPATTERN = rf"[{re.escape(icls.CHARSET)}]+"
22
+ else:
23
+ _IPATTERN = icls.PATTERN
24
+
25
+ if vcls.PATTERN is None:
26
+ _VPATTERN = rf"[{re.escape(vcls.CHARSET)}]+"
27
+ else:
28
+ _VPATTERN = vcls.PATTERN
29
+
30
+
31
+
32
+ class Placeholder(icls):
33
+
34
+ CHARSET = _PREFIX + _SUFFIX + icls.CHARSET
35
+ PATTERN = rf"{re.escape(_PREFIX)}{_IPATTERN}{re.escape(_SUFFIX)}"
36
+
37
+ def __new__(cls, value):
38
+ return super().__new__(cls, value)
39
+
40
+ @classmethod
41
+ def picker(cls, picker:str):
42
+ return _Picker(picker)
43
+
44
+
45
+
46
+ class _Picker:
47
+
48
+ _PICKER_MAPPER_PREFIX = "placeholder_"
49
+
50
+ def __init__(self, picker:str):
51
+ _picker_split = re.split(fr"({Placeholder.PATTERN})", picker)
52
+ _rexp = r""
53
+ _mapper = {}
54
+ _mapper_idx = 0
55
+ for _part in _picker_split:
56
+ if re.match(Placeholder.PATTERN, _part):
57
+ _mapper_name = rf"{_Picker._PICKER_MAPPER_PREFIX}{_mapper_idx}"
58
+ _mapper[_mapper_name] = _part.removeprefix(_PREFIX).removesuffix(_SUFFIX)
59
+ _mapper_idx += 1
60
+ _rexp += fr"(?P<{_mapper_name}>{_VPATTERN})"
61
+ else:
62
+ _rexp += re.escape(_part)
63
+ self._mapper = _mapper
64
+ self._pattern = re.compile(rf"^{_rexp}$")
65
+
66
+ def pick(self, target:str) -> None | dict[icls, vcls]:
67
+ matches = self._pattern.match(target)
68
+ if not matches:
69
+ return None
70
+ return {
71
+ icls(self._mapper[_mapper_name])
72
+ : vcls(matches.group(_mapper_name))
73
+ for _mapper_name in self._mapper
74
+ }
75
+
76
+
77
+
78
+ return Placeholder
79
+