clsproperties 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.
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Publish Python Package to PyPi on Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- name: Download Repository Content to Machine
|
|
13
|
+
uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Set up Python Environment
|
|
16
|
+
uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.x"
|
|
19
|
+
|
|
20
|
+
- name: Install Build Package
|
|
21
|
+
run: python -m pip install --upgrade build
|
|
22
|
+
|
|
23
|
+
- name: Build Package
|
|
24
|
+
run: python -m build
|
|
25
|
+
|
|
26
|
+
- name: Upload Build Artifacts
|
|
27
|
+
uses: actions/upload-artifact@v4
|
|
28
|
+
with:
|
|
29
|
+
name: package-dist
|
|
30
|
+
path: dist/
|
|
31
|
+
|
|
32
|
+
publish:
|
|
33
|
+
needs: build
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
|
|
36
|
+
permissions:
|
|
37
|
+
id-token: write
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- name: Download Build Artifacts
|
|
41
|
+
uses: actions/download-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: package-dist
|
|
44
|
+
path: dist/
|
|
45
|
+
|
|
46
|
+
- name: Publish to PyPI
|
|
47
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
48
|
+
with:
|
|
49
|
+
packages-dir: dist/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Isaac Bell
|
|
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,47 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clsproperties
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Provides classproperty objects for controlled access to class attributes.
|
|
5
|
+
Project-URL: Source, https://github.com/icb08/clsproperties
|
|
6
|
+
Project-URL: Issues, https://github.com/icb08/clsproperties/issues
|
|
7
|
+
Project-URL: Documentation, https://github.com/icb08/clsproperties/wiki/Documentation
|
|
8
|
+
Project-URL: Changelog, https://github.com/icb08/clsproperties/wiki/Changelog
|
|
9
|
+
Project-URL: License, https://github.com/icb08/clsproperties/blob/main/LICENSE
|
|
10
|
+
Author: Isaac Bell
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
Keywords: attribute,attributes,class,classattribute,classattributes,classproperties,classproperty,deleter,descriptor,getter,metaclass,properties,property,pypi,python,python-3,python-library,python-module,python-package,python3,setter
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
29
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
30
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
31
|
+
Requires-Python: >=3.6
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# clsproperties
|
|
35
|
+
- **Author:** [Isaac Bell](https://github.com/icb08)
|
|
36
|
+
- **Version:** [1.0.0](https://github.com/icb08/clsproperties/wiki/Changelog#1-0-0)
|
|
37
|
+
|
|
38
|
+
This library provides `classproperty` objects for controlled access to class attributes.
|
|
39
|
+
|
|
40
|
+
The `classproperty` class aims to emulate the behaviours of Python's built-in `property` class, providing controlled access to class attributes instead of instance attributes. Like `property` objects, `classproperty` objects support use both as a decorator and as a callable. Like `property` objects, `classproperty` objects are descriptors, supporting getter, setter and deleter functions.
|
|
41
|
+
|
|
42
|
+
## Links
|
|
43
|
+
- **[Source Code](https://github.com/icb08/clsproperties)**
|
|
44
|
+
- **[Issues](https://github.com/icb08/clsproperties/issues)**
|
|
45
|
+
- **[Documentation](https://github.com/icb08/clsproperties/wiki/Documentation)**
|
|
46
|
+
- **[Changelog](https://github.com/icb08/clsproperties/wiki/Changelog)**
|
|
47
|
+
- **[License](https://github.com/icb08/clsproperties/blob/main/LICENSE)**
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# clsproperties
|
|
2
|
+
- **Author:** [Isaac Bell](https://github.com/icb08)
|
|
3
|
+
- **Version:** [1.0.0](https://github.com/icb08/clsproperties/wiki/Changelog#1-0-0)
|
|
4
|
+
|
|
5
|
+
This library provides `classproperty` objects for controlled access to class attributes.
|
|
6
|
+
|
|
7
|
+
The `classproperty` class aims to emulate the behaviours of Python's built-in `property` class, providing controlled access to class attributes instead of instance attributes. Like `property` objects, `classproperty` objects support use both as a decorator and as a callable. Like `property` objects, `classproperty` objects are descriptors, supporting getter, setter and deleter functions.
|
|
8
|
+
|
|
9
|
+
## Links
|
|
10
|
+
- **[Source Code](https://github.com/icb08/clsproperties)**
|
|
11
|
+
- **[Issues](https://github.com/icb08/clsproperties/issues)**
|
|
12
|
+
- **[Documentation](https://github.com/icb08/clsproperties/wiki/Documentation)**
|
|
13
|
+
- **[Changelog](https://github.com/icb08/clsproperties/wiki/Changelog)**
|
|
14
|
+
- **[License](https://github.com/icb08/clsproperties/blob/main/LICENSE)**
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# clsproperties
|
|
3
|
+
- **Author:** [Isaac Bell](https://github.com/icb08)
|
|
4
|
+
- **Version:** [1.0.0](https://github.com/icb08/clsproperties/wiki/Changelog#1-0-0)
|
|
5
|
+
|
|
6
|
+
This library provides `classproperty` objects for controlled access to class attributes.
|
|
7
|
+
|
|
8
|
+
The `classproperty` class aims to emulate the behaviours of Python's built-in `property` class, providing controlled access to class attributes instead of instance attributes. Like `property` objects, `classproperty` objects support use both as a decorator and as a callable. Like `property` objects, `classproperty` objects are descriptors, supporting getter, setter and deleter functions.
|
|
9
|
+
|
|
10
|
+
## Links
|
|
11
|
+
- **[Source Code](https://github.com/icb08/clsproperties)**
|
|
12
|
+
- **[Issues](https://github.com/icb08/clsproperties/issues)**
|
|
13
|
+
- **[Documentation](https://github.com/icb08/clsproperties/wiki/Documentation)**
|
|
14
|
+
- **[Changelog](https://github.com/icb08/clsproperties/wiki/Changelog)**
|
|
15
|
+
- **[License](https://github.com/icb08/clsproperties/blob/main/LICENSE)**
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
__author__ = "Isaac Bell"
|
|
19
|
+
__version__ = "1.0.0"
|
|
20
|
+
__all__ = ["classproperty","ClassPropertyMeta"]
|
|
21
|
+
|
|
22
|
+
class classproperty:
|
|
23
|
+
"""
|
|
24
|
+
Class property object.
|
|
25
|
+
|
|
26
|
+
This class defines a `classproperty` descriptor, supporting getter, setter and deleter functions, that aims to emulate the behaviours of Python's built-in `property` class, providing controlled access to class attributes instead of instance attributes. Like `property` objects, `classproperty` objects support use both as a decorator and as a callable.
|
|
27
|
+
|
|
28
|
+
For detailed information on usage and implementation, view the [Documentation](https://github.com/icb08/clsproperties/wiki/Documentation).
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Attributes / Properties
|
|
33
|
+
- **fget** (attribute) : *function*
|
|
34
|
+
> The getter function of the `classproperty` object.
|
|
35
|
+
- **fset** (attribute) : *function*
|
|
36
|
+
> The setter function of the `classproperty` object.
|
|
37
|
+
- **fdel** (attribute) : *function*
|
|
38
|
+
> The deleter function of the `classproperty` object.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Methods / Functions
|
|
43
|
+
- **getter** (instance method)
|
|
44
|
+
> Define the getter function of the `classproperty` object.
|
|
45
|
+
- **setter** (instance method)
|
|
46
|
+
> Define the setter function of the `classproperty` object.
|
|
47
|
+
- **deleter** (instance method)
|
|
48
|
+
> Define the deleter function of the `classproperty` object.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(self,fget=None,fset=None,fdel=None,doc=None):
|
|
52
|
+
"""
|
|
53
|
+
Instantiate a `classproperty` object.
|
|
54
|
+
|
|
55
|
+
This method instantiates a `classproperty` descriptor, defining the getter, setter and deleter functions.
|
|
56
|
+
|
|
57
|
+
For detailed information on usage and implementation, view the [Documentation](https://github.com/icb08/clsproperties/wiki/Documentation).
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Parameters / Arguments
|
|
62
|
+
- **fget** (optional) : *function* (default=None)
|
|
63
|
+
> The getter function of the `classproperty` object.
|
|
64
|
+
- **fset** (optional) : *function* (default=None)
|
|
65
|
+
> The setter function of the `classproperty` object.
|
|
66
|
+
- **fdel** (optional) : *function* (default=None)
|
|
67
|
+
> The deleter function of the `classproperty` object.
|
|
68
|
+
- **doc** (optional) : *str* (default=None)
|
|
69
|
+
> Optional docstring for the `classproperty` object.
|
|
70
|
+
"""
|
|
71
|
+
self.fget = fget
|
|
72
|
+
self.fset = fset
|
|
73
|
+
self.fdel = fdel
|
|
74
|
+
self.__doc__ = doc or (fget.__doc__ if fget else None)
|
|
75
|
+
|
|
76
|
+
def __set_name__(self,cls,name):
|
|
77
|
+
self.__name__ = name
|
|
78
|
+
|
|
79
|
+
def __get__(self,instance,cls=None):
|
|
80
|
+
if cls is None: cls = type(instance)
|
|
81
|
+
if self.fget is None: raise AttributeError(f"Class property '{self.__name__}' of '{cls.__name__}' object has no getter.")
|
|
82
|
+
return self.fget(cls)
|
|
83
|
+
|
|
84
|
+
def __set__(self,instance,value):
|
|
85
|
+
cls = type(instance)
|
|
86
|
+
if self.fset is None: raise AttributeError(f"Class property '{self.__name__}' of '{cls.__name__}' object has no setter.")
|
|
87
|
+
return self.fset(cls,value)
|
|
88
|
+
|
|
89
|
+
def __delete__(self,instance):
|
|
90
|
+
cls = type(instance)
|
|
91
|
+
if self.fdel is None: raise AttributeError(f"Class property '{self.__name__}' of '{cls.__name__}' object has no deleter.")
|
|
92
|
+
return self.fdel(cls)
|
|
93
|
+
|
|
94
|
+
def getter(self,fget):
|
|
95
|
+
"""
|
|
96
|
+
Define the getter function of the `classproperty` object.
|
|
97
|
+
|
|
98
|
+
This method, typically used as a decorator, defines the getter function of the `classproperty` descriptor.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Parameters / Arguments
|
|
103
|
+
- **fget** : *function*
|
|
104
|
+
> The getter function of the `classproperty` object.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Returns
|
|
109
|
+
- *`classproperty` object*
|
|
110
|
+
> Returns a new `classproperty` object, with the specified getter function.
|
|
111
|
+
"""
|
|
112
|
+
return type(self)(fget,self.fset,self.fdel,self.__doc__)
|
|
113
|
+
|
|
114
|
+
def setter(self,fset):
|
|
115
|
+
"""
|
|
116
|
+
Define the setter function of the `classproperty` object.
|
|
117
|
+
|
|
118
|
+
This method, typically used as a decorator, defines the setter function of the `classproperty` descriptor.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Parameters / Arguments
|
|
123
|
+
- **fset** : *function*
|
|
124
|
+
> The setter function of the `classproperty` object.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Returns
|
|
129
|
+
- *`classproperty` object*
|
|
130
|
+
> Returns a new `classproperty` object, with the specified setter function.
|
|
131
|
+
"""
|
|
132
|
+
return type(self)(self.fget,fset,self.fdel,self.__doc__)
|
|
133
|
+
|
|
134
|
+
def deleter(self,fdel):
|
|
135
|
+
"""
|
|
136
|
+
Define the deleter function of the `classproperty` object.
|
|
137
|
+
|
|
138
|
+
This method, typically used as a decorator, defines the deleter function of the `classproperty` descriptor.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Parameters / Arguments
|
|
143
|
+
- **fdel** : *function*
|
|
144
|
+
> The deleter function of the `classproperty` object.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Returns
|
|
149
|
+
- *`classproperty` object*
|
|
150
|
+
> Returns a new `classproperty` object, with the specified deleter function.
|
|
151
|
+
"""
|
|
152
|
+
return type(self)(self.fget,self.fset,fdel,self.__doc__)
|
|
153
|
+
|
|
154
|
+
class ClassPropertyMeta(type):
|
|
155
|
+
"""
|
|
156
|
+
Class property metaclass.
|
|
157
|
+
|
|
158
|
+
This class defines a metaclass, that enables full functionality of `classproperty` objects defined in classes, whose metaclass is `ClassPropertyMeta`. This metaclass intercepts class attribute assignment and deletion operations of `classproperty` objects, and executes the corresponding setter and deleter functions of the `classproperty` objects.
|
|
159
|
+
|
|
160
|
+
For detailed information on usage and implementation, view the [Documentation](https://github.com/icb08/clsproperties/wiki/Documentation).
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Attributes / Properties
|
|
165
|
+
N/A
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Methods / Functions
|
|
170
|
+
N/A
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
def __setattr__(cls,name,value):
|
|
174
|
+
attr = cls.__dict__.get(name)
|
|
175
|
+
if isinstance(attr,classproperty):
|
|
176
|
+
if attr.fset is None: raise AttributeError(f"Class property '{name}' of '{cls}' object has no setter.")
|
|
177
|
+
return attr.fset(cls,value)
|
|
178
|
+
super().__setattr__(name,value)
|
|
179
|
+
|
|
180
|
+
def __delattr__(cls, name):
|
|
181
|
+
attr = cls.__dict__.get(name)
|
|
182
|
+
if isinstance(attr,classproperty):
|
|
183
|
+
if attr.fdel is None: raise AttributeError(f"Class property '{name}' of '{cls}' object has no deleter.")
|
|
184
|
+
return attr.fdel(cls)
|
|
185
|
+
super().__delattr__(name)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "clsproperties"
|
|
7
|
+
authors = [ { name = "Isaac Bell" } ]
|
|
8
|
+
dynamic = ["version"]
|
|
9
|
+
description = "Provides classproperty objects for controlled access to class attributes."
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.6"
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = [ "LICENSE.txt" ]
|
|
14
|
+
|
|
15
|
+
keywords = [
|
|
16
|
+
"python",
|
|
17
|
+
"python3",
|
|
18
|
+
"python-3",
|
|
19
|
+
"python-library",
|
|
20
|
+
"python-package",
|
|
21
|
+
"python-module",
|
|
22
|
+
"pypi",
|
|
23
|
+
"class",
|
|
24
|
+
"metaclass",
|
|
25
|
+
"attribute",
|
|
26
|
+
"attributes",
|
|
27
|
+
"classattribute",
|
|
28
|
+
"classattributes",
|
|
29
|
+
"property",
|
|
30
|
+
"properties",
|
|
31
|
+
"classproperty",
|
|
32
|
+
"classproperties",
|
|
33
|
+
"descriptor",
|
|
34
|
+
"getter",
|
|
35
|
+
"setter",
|
|
36
|
+
"deleter",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
classifiers = [
|
|
40
|
+
"Development Status :: 5 - Production/Stable",
|
|
41
|
+
"Intended Audience :: Developers",
|
|
42
|
+
"License :: OSI Approved :: MIT License",
|
|
43
|
+
"Operating System :: OS Independent",
|
|
44
|
+
"Programming Language :: Python",
|
|
45
|
+
"Programming Language :: Python :: 3",
|
|
46
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
47
|
+
"Programming Language :: Python :: 3.6",
|
|
48
|
+
"Programming Language :: Python :: 3.7",
|
|
49
|
+
"Programming Language :: Python :: 3.8",
|
|
50
|
+
"Programming Language :: Python :: 3.9",
|
|
51
|
+
"Programming Language :: Python :: 3.10",
|
|
52
|
+
"Programming Language :: Python :: 3.11",
|
|
53
|
+
"Programming Language :: Python :: 3.12",
|
|
54
|
+
"Programming Language :: Python :: 3.13",
|
|
55
|
+
"Programming Language :: Python :: 3.14",
|
|
56
|
+
"Topic :: Software Development :: Libraries",
|
|
57
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[project.urls]
|
|
61
|
+
Source = "https://github.com/icb08/clsproperties"
|
|
62
|
+
Issues = "https://github.com/icb08/clsproperties/issues"
|
|
63
|
+
Documentation = "https://github.com/icb08/clsproperties/wiki/Documentation"
|
|
64
|
+
Changelog = "https://github.com/icb08/clsproperties/wiki/Changelog"
|
|
65
|
+
License = "https://github.com/icb08/clsproperties/blob/main/LICENSE"
|
|
66
|
+
|
|
67
|
+
[tool.hatch.version]
|
|
68
|
+
path = "clsproperties/__init__.py"
|