autonomous-app 0.2.25__py3-none-any.whl → 0.3.1__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.
- autonomous/__init__.py +5 -2
- autonomous/ai/audioagent.py +32 -0
- autonomous/ai/imageagent.py +31 -0
- autonomous/ai/jsonagent.py +40 -0
- autonomous/ai/models/__init__.py +0 -0
- autonomous/ai/models/openai.py +308 -0
- autonomous/ai/oaiagent.py +20 -194
- autonomous/ai/textagent.py +35 -0
- autonomous/auth/autoauth.py +11 -11
- autonomous/auth/user.py +24 -11
- autonomous/db/__init__.py +41 -0
- autonomous/db/base/__init__.py +33 -0
- autonomous/db/base/common.py +62 -0
- autonomous/db/base/datastructures.py +476 -0
- autonomous/db/base/document.py +1230 -0
- autonomous/db/base/fields.py +767 -0
- autonomous/db/base/metaclasses.py +468 -0
- autonomous/db/base/utils.py +22 -0
- autonomous/db/common.py +79 -0
- autonomous/db/connection.py +472 -0
- autonomous/db/context_managers.py +313 -0
- autonomous/db/dereference.py +291 -0
- autonomous/db/document.py +1141 -0
- autonomous/db/errors.py +165 -0
- autonomous/db/fields.py +2732 -0
- autonomous/db/mongodb_support.py +24 -0
- autonomous/db/pymongo_support.py +80 -0
- autonomous/db/queryset/__init__.py +28 -0
- autonomous/db/queryset/base.py +2033 -0
- autonomous/db/queryset/field_list.py +88 -0
- autonomous/db/queryset/manager.py +58 -0
- autonomous/db/queryset/queryset.py +189 -0
- autonomous/db/queryset/transform.py +527 -0
- autonomous/db/queryset/visitor.py +189 -0
- autonomous/db/signals.py +59 -0
- autonomous/logger.py +3 -0
- autonomous/model/autoattr.py +120 -0
- autonomous/model/automodel.py +121 -308
- autonomous/storage/imagestorage.py +9 -54
- autonomous/tasks/autotask.py +0 -25
- {autonomous_app-0.2.25.dist-info → autonomous_app-0.3.1.dist-info}/METADATA +7 -8
- autonomous_app-0.3.1.dist-info/RECORD +60 -0
- {autonomous_app-0.2.25.dist-info → autonomous_app-0.3.1.dist-info}/WHEEL +1 -1
- autonomous/db/autodb.py +0 -86
- autonomous/db/table.py +0 -156
- autonomous/errors/__init__.py +0 -1
- autonomous/errors/danglingreferenceerror.py +0 -8
- autonomous/model/autoattribute.py +0 -20
- autonomous/model/orm.py +0 -86
- autonomous/model/serializer.py +0 -110
- autonomous_app-0.2.25.dist-info/RECORD +0 -36
- /autonomous/{storage → apis}/version_control/GHCallbacks.py +0 -0
- /autonomous/{storage → apis}/version_control/GHOrganization.py +0 -0
- /autonomous/{storage → apis}/version_control/GHRepo.py +0 -0
- /autonomous/{storage → apis}/version_control/GHVersionControl.py +0 -0
- /autonomous/{storage → apis}/version_control/__init__.py +0 -0
- /autonomous/{storage → utils}/markdown.py +0 -0
- {autonomous_app-0.2.25.dist-info → autonomous_app-0.3.1.dist-info}/LICENSE +0 -0
- {autonomous_app-0.2.25.dist-info → autonomous_app-0.3.1.dist-info}/top_level.txt +0 -0
autonomous/db/errors.py
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
from collections import defaultdict
|
|
2
|
+
|
|
3
|
+
__all__ = (
|
|
4
|
+
"NotRegistered",
|
|
5
|
+
"InvalidDocumentError",
|
|
6
|
+
"LookUpError",
|
|
7
|
+
"DoesNotExist",
|
|
8
|
+
"MultipleObjectsReturned",
|
|
9
|
+
"InvalidQueryError",
|
|
10
|
+
"OperationError",
|
|
11
|
+
"NotUniqueError",
|
|
12
|
+
"BulkWriteError",
|
|
13
|
+
"FieldDoesNotExist",
|
|
14
|
+
"ValidationError",
|
|
15
|
+
"SaveConditionError",
|
|
16
|
+
"DeprecatedError",
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class MongoEngineException(Exception):
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class NotRegistered(MongoEngineException):
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class InvalidDocumentError(MongoEngineException):
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class LookUpError(AttributeError):
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class DoesNotExist(MongoEngineException):
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class MultipleObjectsReturned(MongoEngineException):
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class InvalidQueryError(MongoEngineException):
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class OperationError(MongoEngineException):
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class NotUniqueError(OperationError):
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class BulkWriteError(OperationError):
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class SaveConditionError(OperationError):
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class FieldDoesNotExist(MongoEngineException):
|
|
65
|
+
"""Raised when trying to set a field
|
|
66
|
+
not declared in a :class:`~autonomous.db.Document`
|
|
67
|
+
or an :class:`~autonomous.db.EmbeddedDocument`.
|
|
68
|
+
|
|
69
|
+
To avoid this behavior on data loading,
|
|
70
|
+
you should set the :attr:`strict` to ``False``
|
|
71
|
+
in the :attr:`meta` dictionary.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ValidationError(AssertionError):
|
|
76
|
+
"""Validation exception.
|
|
77
|
+
|
|
78
|
+
May represent an error validating a field or a
|
|
79
|
+
document containing fields with validation errors.
|
|
80
|
+
|
|
81
|
+
:ivar errors: A dictionary of errors for fields within this
|
|
82
|
+
document or list, or None if the error is for an
|
|
83
|
+
individual field.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
errors = {}
|
|
87
|
+
field_name = None
|
|
88
|
+
_message = None
|
|
89
|
+
|
|
90
|
+
def __init__(self, message="", **kwargs):
|
|
91
|
+
super().__init__(message)
|
|
92
|
+
self.errors = kwargs.get("errors", {})
|
|
93
|
+
self.field_name = kwargs.get("field_name")
|
|
94
|
+
self.message = message
|
|
95
|
+
|
|
96
|
+
def __str__(self):
|
|
97
|
+
return str(self.message)
|
|
98
|
+
|
|
99
|
+
def __repr__(self):
|
|
100
|
+
return f"{self.__class__.__name__}({self.message},)"
|
|
101
|
+
|
|
102
|
+
def __getattribute__(self, name):
|
|
103
|
+
message = super().__getattribute__(name)
|
|
104
|
+
if name == "message":
|
|
105
|
+
if self.field_name:
|
|
106
|
+
message = "%s" % message
|
|
107
|
+
if self.errors:
|
|
108
|
+
message = f"{message}({self._format_errors()})"
|
|
109
|
+
return message
|
|
110
|
+
|
|
111
|
+
def _get_message(self):
|
|
112
|
+
return self._message
|
|
113
|
+
|
|
114
|
+
def _set_message(self, message):
|
|
115
|
+
self._message = message
|
|
116
|
+
|
|
117
|
+
message = property(_get_message, _set_message)
|
|
118
|
+
|
|
119
|
+
def to_dict(self):
|
|
120
|
+
"""Returns a dictionary of all errors within a document
|
|
121
|
+
|
|
122
|
+
Keys are field names or list indices and values are the
|
|
123
|
+
validation error messages, or a nested dictionary of
|
|
124
|
+
errors for an embedded document or list.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
def build_dict(source):
|
|
128
|
+
errors_dict = {}
|
|
129
|
+
if isinstance(source, dict):
|
|
130
|
+
for field_name, error in source.items():
|
|
131
|
+
errors_dict[field_name] = build_dict(error)
|
|
132
|
+
elif isinstance(source, ValidationError) and source.errors:
|
|
133
|
+
return build_dict(source.errors)
|
|
134
|
+
else:
|
|
135
|
+
return str(source)
|
|
136
|
+
|
|
137
|
+
return errors_dict
|
|
138
|
+
|
|
139
|
+
if not self.errors:
|
|
140
|
+
return {}
|
|
141
|
+
|
|
142
|
+
return build_dict(self.errors)
|
|
143
|
+
|
|
144
|
+
def _format_errors(self):
|
|
145
|
+
"""Returns a string listing all errors within a document"""
|
|
146
|
+
|
|
147
|
+
def generate_key(value, prefix=""):
|
|
148
|
+
if isinstance(value, list):
|
|
149
|
+
value = " ".join([generate_key(k) for k in value])
|
|
150
|
+
elif isinstance(value, dict):
|
|
151
|
+
value = " ".join([generate_key(v, k) for k, v in value.items()])
|
|
152
|
+
|
|
153
|
+
results = f"{prefix}.{value}" if prefix else value
|
|
154
|
+
return results
|
|
155
|
+
|
|
156
|
+
error_dict = defaultdict(list)
|
|
157
|
+
for k, v in self.to_dict().items():
|
|
158
|
+
error_dict[generate_key(v)].append(k)
|
|
159
|
+
return " ".join([f"{k}: {v}" for k, v in error_dict.items()])
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class DeprecatedError(MongoEngineException):
|
|
163
|
+
"""Raise when a user uses a feature that has been Deprecated"""
|
|
164
|
+
|
|
165
|
+
pass
|