opalib 0.1.0__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.
- __init__.py +15 -0
- enum_extender.py +47 -0
- opalib-0.1.0.dist-info/METADATA +12 -0
- opalib-0.1.0.dist-info/RECORD +7 -0
- opalib-0.1.0.dist-info/WHEEL +5 -0
- opalib-0.1.0.dist-info/licenses/LICENSE +21 -0
- opalib-0.1.0.dist-info/top_level.txt +2 -0
__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# __init__.py
|
|
2
|
+
import os
|
|
3
|
+
import importlib
|
|
4
|
+
|
|
5
|
+
# Get all .py files in this folder (excluding this file)
|
|
6
|
+
pkg_dir = os.path.dirname(__file__)
|
|
7
|
+
for file in os.listdir(pkg_dir):
|
|
8
|
+
if file.endswith(".py") and file != "__init__.py":
|
|
9
|
+
module_name = file[:-3]
|
|
10
|
+
module = importlib.import_module(f".{module_name}", package=__name__)
|
|
11
|
+
|
|
12
|
+
# Expose everything from the module to the package level
|
|
13
|
+
for attribute in dir(module):
|
|
14
|
+
if not attribute.startswith("_"):
|
|
15
|
+
globals()[attribute] = getattr(module, attribute)
|
enum_extender.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
enum_extender - a Python version of https://github.com/buildthomas/EnumExtender
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from enum import Enum as PyEnum
|
|
6
|
+
|
|
7
|
+
class EnumRegistry:
|
|
8
|
+
def __init__(self):
|
|
9
|
+
self._enums = {}
|
|
10
|
+
|
|
11
|
+
def new(self, name, items):
|
|
12
|
+
if not isinstance(name, str):
|
|
13
|
+
raise TypeError("Enum name must be a string")
|
|
14
|
+
|
|
15
|
+
if not isinstance(items, list) or not all(isinstance(i, str) for i in items):
|
|
16
|
+
raise TypeError("Enum items must be a list of strings")
|
|
17
|
+
|
|
18
|
+
if name in self._enums:
|
|
19
|
+
raise ValueError(f"Enum '{name}' already exists")
|
|
20
|
+
|
|
21
|
+
# Create a real Python Enum class dynamically
|
|
22
|
+
enum_class = PyEnum(name, {item: index for index, item in enumerate(items)})
|
|
23
|
+
|
|
24
|
+
self._enums[name] = enum_class
|
|
25
|
+
return enum_class
|
|
26
|
+
|
|
27
|
+
def __getattr__(self, name):
|
|
28
|
+
if name in self._enums:
|
|
29
|
+
return self._enums[name]
|
|
30
|
+
raise AttributeError(f"Enum '{name}' does not exist")
|
|
31
|
+
|
|
32
|
+
def find(self, name):
|
|
33
|
+
return self._enums.get(name)
|
|
34
|
+
|
|
35
|
+
def from_value(self, enum_name, value):
|
|
36
|
+
enum_class = self._enums.get(enum_name)
|
|
37
|
+
if enum_class is None:
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
for item in enum_class:
|
|
41
|
+
if item.value == value:
|
|
42
|
+
return item
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Exported instance
|
|
47
|
+
Enums = EnumRegistry()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: opalib
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A library to do multiple things
|
|
5
|
+
Author-email: Donovan <donovandelisle7@gmail.com>
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# opalib
|
|
12
|
+
A library to do multiple things
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
__init__.py,sha256=flqJBQOPiDCvWxcWDzF1goh_snlvF7qAVVlUcoHbyK4,557
|
|
2
|
+
enum_extender.py,sha256=FChVNhqXC2_UqJ-hGB-LMhMMaP-0F69NQoLgaAq4ZZY,1315
|
|
3
|
+
opalib-0.1.0.dist-info/licenses/LICENSE,sha256=7qLe4iBXYHYrFXISKw5Bb90JKg8DJtGhFMIVZ2ljATE,1074
|
|
4
|
+
opalib-0.1.0.dist-info/METADATA,sha256=8MJgwTV4Q6jcAjjBFRAmWVTekiDmqQGlKZegRHcNoyw,290
|
|
5
|
+
opalib-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
6
|
+
opalib-0.1.0.dist-info/top_level.txt,sha256=zHIMWAQsa7sn_IDZbcTeCG5AmfupGlm1VjHyiUObA3o,23
|
|
7
|
+
opalib-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeveloperDankyMan
|
|
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.
|