GeneralManager 0.5.1__py3-none-any.whl → 0.5.2__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.
@@ -70,9 +70,17 @@ class InterfaceBase(ABC):
70
70
  *args: Any,
71
71
  **kwargs: dict[str, Any],
72
72
  ) -> dict[str, Any]:
73
+ """
74
+ Parses and validates input arguments into a structured identification dictionary.
75
+
76
+ Converts positional and keyword arguments into a dictionary keyed by input field names, handling normalization of argument names and checking for unexpected or missing arguments. Processes input fields in dependency order, casting and validating each value. Raises a `TypeError` for unexpected or missing arguments and a `ValueError` if circular dependencies among input fields are detected.
77
+
78
+ Returns:
79
+ A dictionary mapping input field names to their validated and cast values.
80
+ """
73
81
  identification = {}
74
82
  kwargs = args_to_kwargs(args, self.input_fields.keys(), kwargs)
75
- # Prüfe auf fehlende oder unerwartete Argumente
83
+ # Check for extra arguments
76
84
  extra_args = set(kwargs.keys()) - set(self.input_fields.keys())
77
85
  if extra_args:
78
86
  for extra_arg in extra_args:
@@ -85,7 +93,7 @@ class InterfaceBase(ABC):
85
93
  if missing_args:
86
94
  raise TypeError(f"Missing required arguments: {', '.join(missing_args)}")
87
95
 
88
- # Verarbeite Felder unter Berücksichtigung von Abhängigkeiten
96
+ # process input fields with dependencies
89
97
  processed = set()
90
98
  while len(processed) < len(self.input_fields):
91
99
  progress_made = False
@@ -100,7 +108,7 @@ class InterfaceBase(ABC):
100
108
  processed.add(name)
101
109
  progress_made = True
102
110
  if not progress_made:
103
- # Zirkuläre Abhängigkeit erkannt
111
+ # detect circular dependencies
104
112
  unresolved = set(self.input_fields.keys()) - processed
105
113
  raise ValueError(
106
114
  f"Circular dependency detected among inputs: {', '.join(unresolved)}"
@@ -123,13 +131,18 @@ class InterfaceBase(ABC):
123
131
  def _process_input(
124
132
  self, name: str, value: Any, identification: dict[str, Any]
125
133
  ) -> None:
134
+ """
135
+ Validates the type and allowed values of an input field.
136
+
137
+ Checks that the provided value matches the expected type for the input field and, in debug mode, verifies that the value is among the allowed possible values if specified. Raises a TypeError for invalid types or possible value definitions, and a ValueError if the value is not permitted.
138
+ """
126
139
  input_field = self.input_fields[name]
127
140
  if not isinstance(value, input_field.type):
128
141
  raise TypeError(
129
142
  f"Invalid type for {name}: {type(value)}, expected: {input_field.type}"
130
143
  )
131
144
  if settings.DEBUG:
132
- # Prüfe mögliche Werte
145
+ # `possible_values` can be a callable or an iterable
133
146
  possible_values = input_field.possible_values
134
147
  if possible_values is not None:
135
148
  if callable(possible_values):
@@ -8,7 +8,6 @@ from typing import (
8
8
  TYPE_CHECKING,
9
9
  Generator,
10
10
  TypeVar,
11
- cast,
12
11
  )
13
12
  from django.db import models, transaction
14
13
  from django.contrib.auth import get_user_model
@@ -646,13 +645,14 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
646
645
  self, basis: dict[str, list[Any]], **kwargs: Any
647
646
  ) -> dict[str, list[Any]]:
648
647
  """
649
- Combines existing filter definitions with additional keyword arguments.
648
+ Merges filter definitions by appending values from keyword arguments to the corresponding lists in the basis dictionary.
650
649
 
651
650
  Args:
652
- basis: Dictionary mapping filter keys to lists of values. Additional keyword arguments are merged into this dictionary.
651
+ basis: A dictionary mapping filter keys to lists of values. Existing filter criteria.
652
+ **kwargs: Additional filter criteria to be merged, where each value is appended to the corresponding key's list.
653
653
 
654
654
  Returns:
655
- A dictionary where each key maps to a list containing all values from both the original basis and the new keyword arguments.
655
+ A dictionary with keys mapping to lists containing all values from both the original basis and the new keyword arguments.
656
656
  """
657
657
  kwarg_filter: dict[str, list[Any]] = {}
658
658
  for key, value in basis.items():
@@ -665,9 +665,9 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
665
665
 
666
666
  def filter(self, **kwargs: Any) -> DatabaseBucket[GeneralManagerType]:
667
667
  """
668
- Returns a new bucket with manager instances matching the specified filter criteria.
668
+ Returns a new bucket containing manager instances matching the given filter criteria.
669
669
 
670
- Additional filter keyword arguments are merged with any existing filters to further restrict the queryset.
670
+ Additional filter keyword arguments are merged with existing filters to further restrict the queryset.
671
671
  """
672
672
  merged_filter = self.__mergeFilterDefinitions(self.filters, **kwargs)
673
673
  return self.__class__(
@@ -679,9 +679,9 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
679
679
 
680
680
  def exclude(self, **kwargs: Any) -> DatabaseBucket[GeneralManagerType]:
681
681
  """
682
- Returns a new DatabaseBucket excluding items that match the specified criteria.
682
+ Returns a new DatabaseBucket excluding items matching the given criteria.
683
683
 
684
- Keyword arguments specify field lookups to exclude from the queryset. The resulting bucket contains only items that do not match these filters.
684
+ Keyword arguments define field lookups to exclude from the queryset. The returned bucket contains only items that do not match these filters.
685
685
  """
686
686
  merged_exclude = self.__mergeFilterDefinitions(self.excludes, **kwargs)
687
687
  return self.__class__(
@@ -43,16 +43,19 @@ class GroupBucket(Bucket[GeneralManagerType]):
43
43
 
44
44
  def __checkGroupByArguments(self, group_by_keys: tuple[str, ...]) -> None:
45
45
  """
46
- This method checks if the given arguments are valid for the groupBy method.
47
- It raises a TypeError if the arguments are not valid.
46
+ Validates that all group-by keys are strings and valid attributes of the manager class.
47
+
48
+ Raises:
49
+ TypeError: If any group-by key is not a string.
50
+ ValueError: If any group-by key is not a valid attribute of the manager class.
48
51
  """
49
52
  if not all(isinstance(arg, str) for arg in group_by_keys):
50
53
  raise TypeError("groupBy() argument must be a string")
51
54
  if not all(
52
- arg in self._manager_class.Interface.getAttributes().keys()
55
+ arg in self._manager_class.Interface.getAttributes()
53
56
  for arg in group_by_keys
54
57
  ):
55
- raise TypeError(
58
+ raise ValueError(
56
59
  f"groupBy() argument must be a valid attribute of {self._manager_class.__name__}"
57
60
  )
58
61
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GeneralManager
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: Kurzbeschreibung deines Pakets
5
5
  Author-email: Tim Kleindick <tkleindick@yahoo.de>
6
6
  License-Expression: MIT
@@ -37,51 +37,51 @@ Dynamic: license-file
37
37
 
38
38
  # GeneralManager
39
39
 
40
- ## Überblick
40
+ ## Overview
41
41
 
42
- Das GeneralManager-Modul ist ein leistungsstarkes und flexibles Framework, das speziell für die Verwaltung und Verarbeitung von Daten entwickelt wurde. Es bietet eine modulare Struktur, die es Entwicklern ermöglicht, komplexe Geschäftslogiken effizient zu implementieren und zu verwalten. Das Modul ist vollständig in Python geschrieben und nutzt Django als Backend-Framework.
42
+ GeneralManager is a powerful and flexible framework designed for managing and processing data. It provides a modular structure that enables developers to implement complex business logic efficiently. The module is written entirely in Python and uses Django as the backend framework.
43
43
 
44
- ## Hauptfunktionen
44
+ ## Key Features
45
45
 
46
- ### 1. **Datenmanagement**
47
- - **Flexibilität**: Unterstützt die Verwaltung aller Arten von Daten, nicht nur Projekte und Derivate.
48
- - **Datenbank-Integration**: Nahtlose Integration mit dem Django ORM für Datenbankoperationen.
49
- - **Externe Schnittstellen**: Unterstützung für Schnittstellen zu anderen Programmen, wie z. B. Excel-Interfaces.
46
+ ### 1. **Data Management**
47
+ - **Flexibility**: Supports managing all kinds of data, not just projects and derivatives.
48
+ - **Database Integration**: Seamless integration with the Django ORM for database operations.
49
+ - **External Interfaces**: Support for interfaces to other programs, such as Excel.
50
50
 
51
- ### 2. **Datenmodellierung**
52
- - **Django-Modelle**: Die Datenstruktur basiert auf Django-Modellen, die durch benutzerdefinierte Felder wie `MeasurementField` erweitert werden.
53
- - **Regeln und Validierungen**: Definieren Sie Regeln für Datenvalidierungen, z. B. dass das Startdatum eines Projekts vor dem Enddatum liegen muss.
51
+ ### 2. **Data Modeling**
52
+ - **Django Models**: The data structure is based on Django models, extended by custom fields like `MeasurementField`.
53
+ - **Rules and Validations**: Define rules for data validation, e.g., ensuring that a project's start date is before its end date.
54
54
 
55
- ### 3. **GraphQL-Integration**
56
- - Automatische Generierung von GraphQL-Schnittstellen für alle Modelle.
57
- - Unterstützung für benutzerdefinierte Abfragen und Mutationen.
55
+ ### 3. **GraphQL Integration**
56
+ - Automatic generation of GraphQL interfaces for all models.
57
+ - Support for custom queries and mutations.
58
58
 
59
- ### 4. **Berechtigungssystem**
60
- - **ManagerBasedPermission**: Ein flexibles Berechtigungssystem, das auf Benutzerrollen und Attributen basiert.
61
- - Unterstützung für CRUD-Berechtigungen auf Attributebene.
59
+ ### 4. **Permission System**
60
+ - **ManagerBasedPermission**: A flexible permission system based on user roles and attributes.
61
+ - Attribute-level CRUD permissions.
62
62
 
63
63
  ### 5. **Interfaces**
64
- - **CalculationInterface**: Ermöglicht die Implementierung von Berechnungslogiken.
65
- - **DatabaseInterface**: Bietet eine standardisierte Schnittstelle für Datenbankoperationen.
66
- - **ReadOnlyInterface**: Für schreibgeschützte Datenzugriffe.
64
+ - **CalculationInterface**: Allows the implementation of calculation logic.
65
+ - **DatabaseInterface**: Provides a standardized interface for database operations.
66
+ - **ReadOnlyInterface**: For read-only data access.
67
67
 
68
- ### 6. **Datenverteilung und Berechnung**
69
- - **Volumenverteilung**: Automatische Berechnung und Verteilung von Volumen über mehrere Jahre.
70
- - **Kommerzielle Berechnungen**: Berechnung von Gesamtvolumen, Versandkosten und Einnahmen für Projekte.
68
+ ### 6. **Data Distribution and Calculations**
69
+ - **Volume Distribution**: Automatically calculates and distributes volume over multiple years.
70
+ - **Commercial Calculations**: Calculates total volume, shipping costs, and revenue for projects.
71
71
 
72
- ## Anwendung
72
+ ## Usage
73
73
 
74
74
  ### Installation
75
75
 
76
- Installieren Sie das Modul über `pip`:
76
+ Install the module via `pip`:
77
77
 
78
78
  ```bash
79
79
  pip install GeneralManager
80
80
  ```
81
81
 
82
- ### Beispielcode
82
+ ### Example Code
83
83
 
84
- Hier ist ein Beispiel, wie Sie einen GeneralManager erstellen und Testdaten (in diesem Fall 10 Projekte) generieren können:
84
+ The following example demonstrates how to create a GeneralManager and generate sample data (in this case 10 projects):
85
85
 
86
86
  ```python
87
87
  from general_manager import GeneralManager
@@ -134,11 +134,11 @@ class Project(GeneralManager):
134
134
  Project.Factory.createBatch(10)
135
135
  ```
136
136
 
137
- ### GraphQL-Integration
137
+ ### GraphQL Integration
138
138
 
139
- Das Modul generiert automatisch GraphQL-Schnittstellen für alle Modelle. Sie können Abfragen und Mutationen über die GraphQL-URL ausführen, die in den Django-Einstellungen definiert ist.
139
+ The module automatically generates GraphQL endpoints for all models. You can run queries and mutations through the GraphQL URL defined in your Django settings.
140
140
 
141
- Beispiel für eine GraphQL-Abfrage:
141
+ Example of a GraphQL query:
142
142
 
143
143
  ```graphql
144
144
  query {
@@ -154,26 +154,26 @@ query {
154
154
  }
155
155
  ```
156
156
 
157
- ## Vorteile
157
+ ## Benefits
158
158
 
159
- - **Modularität**: Einfach erweiterbar und anpassbar.
160
- - **Flexibilität**: Unterstützt komplexe Geschäftslogiken und Berechnungen.
161
- - **Integration**: Nahtlose Integration mit Django und GraphQL.
162
- - **Berechtigungen**: Fein abgestimmte Berechtigungen für Benutzer und Attribute.
163
- - **Datenvalidierung**: Automatische Validierung von Daten durch Regeln und Constraints.
164
- - **Caching**: Automatische Cache-Generierung mit @cached Decorator, um die Leistung zu verbessern.
159
+ - **Modularity**: Easy to extend and adapt.
160
+ - **Flexibility**: Supports complex business logic and calculations.
161
+ - **Integration**: Seamless integration with Django and GraphQL.
162
+ - **Permissions**: Fine-grained permissions for users and attributes.
163
+ - **Data Validation**: Automatic validation of data through rules and constraints.
164
+ - **Caching**: Automatic cache generation with the `@cached` decorator to improve performance.
165
165
 
166
- ## Anforderungen
166
+ ## Requirements
167
167
 
168
168
  - Python >= 3.12
169
169
  - Django >= 5.2
170
- - Zusätzliche Abhängigkeiten (siehe `requirements.txt`):
170
+ - Additional dependencies (see `requirements.txt`):
171
171
  - `graphene`
172
172
  - `numpy`
173
173
  - `Pint`
174
174
  - `factory_boy`
175
- - uvm.
175
+ - and more.
176
176
 
177
- ## Lizenz
177
+ ## License
178
178
 
179
- Dieses Projekt steht unter der **Non-Commercial MIT License**. Es darf nur für nicht-kommerzielle Zwecke verwendet werden. Weitere Details finden Sie in der [LICENSE](./LICENSE).
179
+ This project is distributed under the **Non-Commercial MIT License**. It may only be used for non-commercial purposes. For further details see the [LICENSE](./LICENSE) file.
@@ -20,12 +20,12 @@ general_manager/factory/autoFactory.py,sha256=WBhSuMVsxkPAPLhlZhYXwHVIqiomUveS7v
20
20
  general_manager/factory/factories.py,sha256=F6_nYFyJRYYc3LQApfoVFdctfLzsWUDHKafn6xjckB8,7224
21
21
  general_manager/factory/factoryMethods.py,sha256=9Bag891j0XHe3dUBAFi7gUKcKeUwcBZN3cDLBobyBiI,3225
22
22
  general_manager/interface/__init__.py,sha256=6x5adQLefTugvrJeyPcAxstyqgLAYeaJ1EPdAbac9pE,213
23
- general_manager/interface/baseInterface.py,sha256=di6yUxosJCDVyMypJAHdlf0-nhXfhVTW1EKWYCoglNQ,10261
23
+ general_manager/interface/baseInterface.py,sha256=V8AzZ9CwswZAqc2aODmE_7DtqokOkOxzpXFVQ6qznMo,11271
24
24
  general_manager/interface/calculationInterface.py,sha256=GzSNXjU6Z7bFz60gHyMKkI5xNUDIPuniV8wbyVtQT50,14250
25
- general_manager/interface/databaseInterface.py,sha256=1hQcgOQkEhniv7Mrx2CbqPaes_qqH9zTqSnlriZQfGo,28314
25
+ general_manager/interface/databaseInterface.py,sha256=khzqoOcKrBSaYnZAdPmm9cdseNx4YdPRqx5B-81KGf4,28431
26
26
  general_manager/manager/__init__.py,sha256=l3RYp62aEhj3Y975_XUTIzo35LUnkTJHkb_hgChnXXI,111
27
27
  general_manager/manager/generalManager.py,sha256=L470Jevvh87doI5leUbTa9P6weIdekRZ6OTorqN-WpY,6091
28
- general_manager/manager/groupManager.py,sha256=Ge5WtUXE-x2Z9PtjJ2wa31WED_H7UvnX3x1hUCGp7d8,10476
28
+ general_manager/manager/groupManager.py,sha256=gT7cLq3d6PhsLfVGaIG5-fC7xnwN-4nT46N2WpnSesY,10588
29
29
  general_manager/manager/input.py,sha256=iKawV3P1QICz-0AQUF00OvH7LZYxussg3svpvCUl8hE,2977
30
30
  general_manager/manager/meta.py,sha256=Km4axFpDKI_Wx000dOok5jUwjJVqq5QJG9XhrWRw5mo,3624
31
31
  general_manager/measurement/__init__.py,sha256=X97meFujBldE5v0WMF7SmKeGpC5R0JTczfLo_Lq1Xek,84
@@ -40,8 +40,8 @@ general_manager/permission/permissionDataManager.py,sha256=Ji7fsnuaKTa6M8yzCGyzr
40
40
  general_manager/rule/__init__.py,sha256=4Har5cfPD1fmOsilTDod-ZUz3Com-tkl58jz7yY4fD0,23
41
41
  general_manager/rule/handler.py,sha256=z8SFHTIZ0LbLh3fV56Mud0V4_OvWkqJjlHvFqau7Qfk,7334
42
42
  general_manager/rule/rule.py,sha256=3FVCKGL7BTVoStdgOTdWQwuoVRIxAIAilV4VOzouDpc,10759
43
- generalmanager-0.5.1.dist-info/licenses/LICENSE,sha256=YGFm0ieb4KpkMRRt2qnWue6uFh0cUMtobwEBkHwajhc,1450
44
- generalmanager-0.5.1.dist-info/METADATA,sha256=v2MleXEYMzDIUCyvT5bjv3vJgdran7wyPFKk-C4F7mM,6528
45
- generalmanager-0.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
46
- generalmanager-0.5.1.dist-info/top_level.txt,sha256=sTDtExP9ga-YP3h3h42yivUY-A2Q23C2nw6LNKOho4I,16
47
- generalmanager-0.5.1.dist-info/RECORD,,
43
+ generalmanager-0.5.2.dist-info/licenses/LICENSE,sha256=YGFm0ieb4KpkMRRt2qnWue6uFh0cUMtobwEBkHwajhc,1450
44
+ generalmanager-0.5.2.dist-info/METADATA,sha256=7fumKNtzVKr86HwflW_Sesa93yWWHXTJAyumR-TWDEU,6101
45
+ generalmanager-0.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
46
+ generalmanager-0.5.2.dist-info/top_level.txt,sha256=sTDtExP9ga-YP3h3h42yivUY-A2Q23C2nw6LNKOho4I,16
47
+ generalmanager-0.5.2.dist-info/RECORD,,