update code
This commit is contained in:
2025-06-26 06:52:33 +03:00
parent 488e62a9c3
commit 97f1839014
8 changed files with 150 additions and 65 deletions

20
docs/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

2
docs/build/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

28
docs/source/conf.py Normal file
View File

@@ -0,0 +1,28 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'configurator'
copyright = '2025, RemiZOffAlex'
author = 'RemiZOffAlex'
release = '1.0'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = []
templates_path = ['_templates']
exclude_patterns = []
language = 'ru'
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'alabaster'
html_static_path = ['_static']

16
docs/source/index.rst Normal file
View File

@@ -0,0 +1,16 @@
.. configurator documentation master file, created by
sphinx-quickstart on Thu Jun 26 06:07:35 2025.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Configurator
============
Add your content using ``reStructuredText`` syntax. See the
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
documentation for details.
.. toctree::
:maxdepth: 2
:caption: Contents:

View File

@@ -1,6 +1,6 @@
[project]
name = "configurator"
version ="0.1"
version ="1.0"
authors = [
{ name="RemiZOffAlex", email="remizoffalex@gmail.com" },
]
@@ -22,14 +22,15 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Code Generators",
"Topic :: Software Development :: Compilers",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: System",
"Topic :: System :: Systems Administration",
"Topic :: Software Development :: Libraries",
]
keywords = ["config", "configurator", "configuration management"]
dependencies = [
"pyyaml",
"middleware@git+https://codex.r10x.net/RemiZOffAlex/middleware",
]
[build-system]

View File

@@ -1,61 +0,0 @@
__author__ = 'RemiZOffAlex'
__email__ = 'remizoffalex@mail.ru'
from middleware.common import middleware
class Config:
@middleware
def __init__(self, value):
self.__value__ = value
@middleware
def __contains__(self, key):
if key in self.__value__:
return True
else:
return False
@middleware
def __delitem__(self, key):
del self.__value__[key]
@middleware
def __getattr__(self, key):
value = self.__value__[key]
if isinstance(value, dict):
result = Config(value)
elif isinstance(value, list):
result = Config(value)
else:
result = value
return result
@middleware
def __getitem__(self, key):
# if isinstance(self.__value__, dict):
value = self.__value__[key]
if isinstance(value, dict):
result = Config(value)
elif isinstance(value, list):
result = Config(value)
else:
result = value
return result
@middleware
def __iter__(self):
for name in self.__value__.keys():
yield name
@middleware
def __len__(self):
return len(self.__value__)
@middleware
def __repr__(self):
return '<{cls} at {id}>'.format(cls=self.__class__.__name__, id=id(self))
@middleware
def __setitem__(self, key, value):
self.__value__[key] = value

View File

@@ -0,0 +1,79 @@
__author__ = 'RemiZOffAlex'
__email__ = 'remizoffalex@mail.ru'
class Config:
def __add__(self, other=None):
print('self', self)
print('other', len(other))
if other:
print('__add__', other)
print(self.__value)
print(other.__value)
print(self.__value | other.__value)
self.__value = self.__value | other.__value
return self
def __init__(self, value: dict = {}):
self.__value = value
def __contains__(self, key):
if key in self.__value:
return True
else:
return False
def __delitem__(self, key):
del self.__value[key]
def __getattr__(self, key):
if key.startswith('_'):
raise AttributeError(key)
def _getattr(obj, attr):
pass
print(self.__value)
print(key)
if key=='items' and isinstance(self.__value, dict):
return self.__value.items
value = self.__value[key]
if isinstance(value, dict | list):
result = Config(value)
else:
result = value
return result
def __getitem__(self, key):
print('__getitem__:', key)
# if isinstance(self.__value, dict):
value = self.__value[key]
if isinstance(value, dict):
result = Config(value)
elif isinstance(value, list):
result = Config(value)
else:
result = value
return result
def __iter__(self):
print('__iter__', type(self.__value))
if isinstance(self.__value, list):
for value in self.__value:
yield value
else:
for name in self.__value.keys():
yield name
def __len__(self):
return len(self.__value)
def __repr__(self):
return '<{cls} at {id}>'.format(cls=self.__class__.__name__, id=id(self))
def __setitem__(self, key, value):
self.__value[key] = value
def merge(self, condition, config):
for key in config:
self.__value[key] = config[key]