strictaccess 0.1.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.
- strictaccess-0.1.0/LICENSE +16 -0
- strictaccess-0.1.0/PKG-INFO +27 -0
- strictaccess-0.1.0/README.md +12 -0
- strictaccess-0.1.0/setup.cfg +4 -0
- strictaccess-0.1.0/setup.py +20 -0
- strictaccess-0.1.0/strictaccess/__init__.py +4 -0
- strictaccess-0.1.0/strictaccess/access_tags.py +11 -0
- strictaccess-0.1.0/strictaccess/core.py +36 -0
- strictaccess-0.1.0/strictaccess/decorators.py +13 -0
- strictaccess-0.1.0/strictaccess/exceptions.py +11 -0
- strictaccess-0.1.0/strictaccess.egg-info/PKG-INFO +27 -0
- strictaccess-0.1.0/strictaccess.egg-info/SOURCES.txt +12 -0
- strictaccess-0.1.0/strictaccess.egg-info/dependency_links.txt +1 -0
- strictaccess-0.1.0/strictaccess.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
---
|
|
3
|
+
|
|
4
|
+
## 📄 `LICENSE`
|
|
5
|
+
Ubicación: `strictaccess/LICENSE`
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 Jhoel Peralta
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: strictaccess
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Enforces strict access control for Python classes, with strict mode and access decorators.
|
|
5
|
+
Home-page: https://github.com/jhoelperalta/strictaccess
|
|
6
|
+
Author: Jhoel Peralta
|
|
7
|
+
Author-email: jhoelperaltap@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
|
|
16
|
+
# strictaccess
|
|
17
|
+
|
|
18
|
+
Paquete Python para imponer control estricto de acceso (`private`, `protected`, `public`) en clases de Python, similar a lenguajes como Java o C++.
|
|
19
|
+
|
|
20
|
+
## CaracterÃsticas
|
|
21
|
+
- Protege atributos y métodos.
|
|
22
|
+
- Soporta modo Debug para desarrollo.
|
|
23
|
+
- Decoradores `@private`, `@protected`, `@public`.
|
|
24
|
+
|
|
25
|
+
## Instalación
|
|
26
|
+
```bash
|
|
27
|
+
pip install strictaccess
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# strictaccess
|
|
2
|
+
|
|
3
|
+
Paquete Python para imponer control estricto de acceso (`private`, `protected`, `public`) en clases de Python, similar a lenguajes como Java o C++.
|
|
4
|
+
|
|
5
|
+
## Características
|
|
6
|
+
- Protege atributos y métodos.
|
|
7
|
+
- Soporta modo Debug para desarrollo.
|
|
8
|
+
- Decoradores `@private`, `@protected`, `@public`.
|
|
9
|
+
|
|
10
|
+
## Instalación
|
|
11
|
+
```bash
|
|
12
|
+
pip install strictaccess
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='strictaccess',
|
|
5
|
+
version='0.1.0',
|
|
6
|
+
description='Enforces strict access control for Python classes, with strict mode and access decorators.',
|
|
7
|
+
long_description=open('README.md').read(),
|
|
8
|
+
long_description_content_type='text/markdown',
|
|
9
|
+
author='Jhoel Peralta',
|
|
10
|
+
author_email='jhoelperaltap@gmail.com',
|
|
11
|
+
url='https://github.com/jhoelperalta/strictaccess',
|
|
12
|
+
packages=find_packages(),
|
|
13
|
+
python_requires='>=3.7',
|
|
14
|
+
license='MIT',
|
|
15
|
+
classifiers=[
|
|
16
|
+
'Programming Language :: Python :: 3',
|
|
17
|
+
'License :: OSI Approved :: MIT License',
|
|
18
|
+
'Operating System :: OS Independent',
|
|
19
|
+
],
|
|
20
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
from .exceptions import PrivateAccessError, ProtectedAccessError
|
|
3
|
+
|
|
4
|
+
class AccessControlMixin:
|
|
5
|
+
_debug_mode = False # Default no debug
|
|
6
|
+
|
|
7
|
+
def __getattribute__(self, name):
|
|
8
|
+
value = super().__getattribute__(name)
|
|
9
|
+
|
|
10
|
+
if name.startswith('__') and not name.endswith('__'):
|
|
11
|
+
self._handle_violation('private', name)
|
|
12
|
+
elif name.startswith('_') and not name.startswith('__'):
|
|
13
|
+
caller = inspect.stack()[1].frame.f_locals.get('self', None)
|
|
14
|
+
if caller is not self:
|
|
15
|
+
self._handle_violation('protected', name)
|
|
16
|
+
|
|
17
|
+
# Check access level for methods
|
|
18
|
+
if callable(value):
|
|
19
|
+
access_level = getattr(value, '_access_level', None)
|
|
20
|
+
if access_level == 'private':
|
|
21
|
+
self._handle_violation('private', name)
|
|
22
|
+
elif access_level == 'protected':
|
|
23
|
+
caller = inspect.stack()[1].frame.f_locals.get('self', None)
|
|
24
|
+
if caller is not self:
|
|
25
|
+
self._handle_violation('protected', name)
|
|
26
|
+
|
|
27
|
+
return value
|
|
28
|
+
|
|
29
|
+
def _handle_violation(self, level, name):
|
|
30
|
+
if self._debug_mode:
|
|
31
|
+
print(f"[DEBUG] Access {level.upper()} violation: {name}")
|
|
32
|
+
else:
|
|
33
|
+
if level == 'private':
|
|
34
|
+
raise PrivateAccessError(f"Access to private member '{name}' is forbidden.")
|
|
35
|
+
elif level == 'protected':
|
|
36
|
+
raise ProtectedAccessError(f"Access to protected member '{name}' is forbidden.")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .core import AccessControlMixin
|
|
2
|
+
|
|
3
|
+
def strict_access_control(debug=False):
|
|
4
|
+
def decorator(cls):
|
|
5
|
+
class Wrapped(AccessControlMixin, cls):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
Wrapped._debug_mode = debug
|
|
9
|
+
Wrapped.__name__ = cls.__name__
|
|
10
|
+
Wrapped.__doc__ = cls.__doc__
|
|
11
|
+
return Wrapped
|
|
12
|
+
|
|
13
|
+
return decorator
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class AccessControlError(Exception):
|
|
2
|
+
"""Base class for access control exceptions."""
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
class PrivateAccessError(AccessControlError):
|
|
6
|
+
"""Raised when trying to access a private attribute or method."""
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
class ProtectedAccessError(AccessControlError):
|
|
10
|
+
"""Raised when trying to access a protected attribute or method."""
|
|
11
|
+
pass
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: strictaccess
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Enforces strict access control for Python classes, with strict mode and access decorators.
|
|
5
|
+
Home-page: https://github.com/jhoelperalta/strictaccess
|
|
6
|
+
Author: Jhoel Peralta
|
|
7
|
+
Author-email: jhoelperaltap@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
|
|
16
|
+
# strictaccess
|
|
17
|
+
|
|
18
|
+
Paquete Python para imponer control estricto de acceso (`private`, `protected`, `public`) en clases de Python, similar a lenguajes como Java o C++.
|
|
19
|
+
|
|
20
|
+
## CaracterÃsticas
|
|
21
|
+
- Protege atributos y métodos.
|
|
22
|
+
- Soporta modo Debug para desarrollo.
|
|
23
|
+
- Decoradores `@private`, `@protected`, `@public`.
|
|
24
|
+
|
|
25
|
+
## Instalación
|
|
26
|
+
```bash
|
|
27
|
+
pip install strictaccess
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
strictaccess/__init__.py
|
|
5
|
+
strictaccess/access_tags.py
|
|
6
|
+
strictaccess/core.py
|
|
7
|
+
strictaccess/decorators.py
|
|
8
|
+
strictaccess/exceptions.py
|
|
9
|
+
strictaccess.egg-info/PKG-INFO
|
|
10
|
+
strictaccess.egg-info/SOURCES.txt
|
|
11
|
+
strictaccess.egg-info/dependency_links.txt
|
|
12
|
+
strictaccess.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
strictaccess
|