memorymanagement 1.4.2__tar.gz → 1.4.4__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.
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/PKG-INFO +1 -1
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement/pointers/core.py +59 -32
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement.egg-info/PKG-INFO +1 -1
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/setup.cfg +1 -1
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/LICENSE +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/README.md +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement/__init__.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement/cleaning/__init__.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement/cleaning/core.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement/pointers/__init__.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement/pointers/decorators.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement.egg-info/SOURCES.txt +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement.egg-info/dependency_links.txt +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement.egg-info/top_level.txt +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.4}/pyproject.toml +0 -0
|
@@ -83,7 +83,7 @@ class Pointer(Generic[PT]):
|
|
|
83
83
|
|
|
84
84
|
Literals are **not** supported because of it being useless. Literals do **not** work anymore.
|
|
85
85
|
The only use for introducing a literal instead of a referenced value is for the class code to bind the instance
|
|
86
|
-
to an unknown reference pointing to the given value or to display all the references pointing to the given literal
|
|
86
|
+
to an unknown reference pointing to the given value or to display all the references pointing to the given literal, through the `get_refs` or `print_refs` methods,
|
|
87
87
|
if there is more than one.
|
|
88
88
|
"""
|
|
89
89
|
#* METHODS
|
|
@@ -110,17 +110,16 @@ class Pointer(Generic[PT]):
|
|
|
110
110
|
# Take the global frame
|
|
111
111
|
vars_dict=vars(modules["__main__"])
|
|
112
112
|
|
|
113
|
-
# Store hidden attributes
|
|
114
|
-
self._value=value # Pointer's value
|
|
115
|
-
self._vars_dict=vars_dict # Variables' frame
|
|
113
|
+
# Store hidden attributes "_attr" and "_vars_dict"
|
|
116
114
|
self._attr=attr # Instance attribute to point to
|
|
115
|
+
self._vars_dict=vars_dict # Variables' frame
|
|
117
116
|
|
|
118
|
-
# If
|
|
119
|
-
if
|
|
120
|
-
# Raise
|
|
121
|
-
raise
|
|
122
|
-
#
|
|
123
|
-
|
|
117
|
+
# If no value or reference is given
|
|
118
|
+
if not value and not reference:
|
|
119
|
+
# Raise a "ValueError"
|
|
120
|
+
raise ValueError("Either a value or a reference is needed")
|
|
121
|
+
# Else, if a reference is given
|
|
122
|
+
elif value and reference:
|
|
124
123
|
# If the reference is in the variables' frame and points to the given value
|
|
125
124
|
if reference in vars_dict and vars_dict[reference] is value:
|
|
126
125
|
# Store the reference in "name" local variable
|
|
@@ -133,18 +132,42 @@ class Pointer(Generic[PT]):
|
|
|
133
132
|
elif vars_dict[reference] is not value:
|
|
134
133
|
# Raise a "ValueError"
|
|
135
134
|
raise ValueError(f"Name \"{reference}\" doesn't point to given value ({value})")
|
|
136
|
-
# Else
|
|
135
|
+
# Else, if only a reference is given
|
|
136
|
+
elif reference:
|
|
137
|
+
# If the given reference is in the variables' frame
|
|
138
|
+
if reference in vars_dict:
|
|
139
|
+
# Store the reference into local variable "name"
|
|
140
|
+
name=reference
|
|
141
|
+
# Store the value the reference is pointing to in argument "value"
|
|
142
|
+
value=vars_dict[reference]
|
|
143
|
+
# Else
|
|
144
|
+
else:
|
|
145
|
+
# Raise a "NameError"
|
|
146
|
+
raise NameError(f"Name \"{reference}\" is not defined")
|
|
147
|
+
# Else, if only a value is given an it is between the variables' frame's values
|
|
148
|
+
elif value and value in vars_dict.values():
|
|
149
|
+
# Loop for the variables' frame
|
|
150
|
+
for key,v in vars_dict.items():
|
|
151
|
+
# If the current value is the given value
|
|
152
|
+
if v is value:
|
|
153
|
+
# The current key is the reference
|
|
154
|
+
name=key
|
|
155
|
+
# Break
|
|
156
|
+
break
|
|
157
|
+
# Else (value not referenced)
|
|
137
158
|
else:
|
|
138
|
-
#
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
159
|
+
# Raise a "NameError"
|
|
160
|
+
raise NameError(f"No reference is pointing to given value \"{value}\" ({value.__class__.__name__})")
|
|
161
|
+
|
|
162
|
+
# Set argument "value" as the pointer's value
|
|
163
|
+
self._value=value
|
|
142
164
|
# Store the reference in the hidden attribute "_name"
|
|
143
165
|
self._name=name
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
166
|
+
|
|
167
|
+
# If there is an instance's attribute to point to and it doesn't belong to the given value
|
|
168
|
+
if attr and attr not in dir(value):
|
|
169
|
+
# Raise an "AttributeError"
|
|
170
|
+
raise AttributeError(f"\"{attr}\" is not an attribute of \"{value}\"")
|
|
148
171
|
|
|
149
172
|
# Point to
|
|
150
173
|
def point_to(self,value=None,reference:str|None=None,*,attr:str|None=None):
|
|
@@ -153,15 +176,15 @@ class Pointer(Generic[PT]):
|
|
|
153
176
|
|
|
154
177
|
Arguments
|
|
155
178
|
---------
|
|
156
|
-
reference : `str`|`None`, Optional
|
|
157
|
-
Reference pointing to the desired value. If wanted class attribute, introduce the reference for the class instance.
|
|
158
179
|
value : `Any`|`None`, Optional
|
|
159
180
|
Value to point to. If wanted class attribute, introduce just the class object.
|
|
181
|
+
reference : `str`|`None`, Optional
|
|
182
|
+
Reference pointing to the desired value. If wanted class attribute, introduce the reference for the class instance.
|
|
160
183
|
attr : `str`|`None`, Optional
|
|
161
184
|
Attribute of the class if class object was passed through `reference` or `value`.
|
|
162
185
|
"""
|
|
163
186
|
# If no reference or value is given
|
|
164
|
-
if not
|
|
187
|
+
if not value and not reference:
|
|
165
188
|
# If an instance's attribute name is given
|
|
166
189
|
if attr:
|
|
167
190
|
# If the attribute belongs to the pointer's value
|
|
@@ -220,16 +243,16 @@ class Pointer(Generic[PT]):
|
|
|
220
243
|
else:
|
|
221
244
|
# Raise a "NameError"
|
|
222
245
|
raise NameError(f"Name \"{reference}\" is not defined")
|
|
223
|
-
# Else, if only a value is given
|
|
224
|
-
elif value:
|
|
225
|
-
#
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
246
|
+
# Else, if only a value is given an it is between the variables' frame's values
|
|
247
|
+
elif value and value in self._vars_dict:
|
|
248
|
+
# Loop for the variables' frame
|
|
249
|
+
for key,v in self._vars_dict.items():
|
|
250
|
+
# If the current value is the given value
|
|
251
|
+
if v is value:
|
|
252
|
+
# The current key is the reference and the given value is set as pointer's value
|
|
253
|
+
self._name,self._value=key,value
|
|
254
|
+
# Break
|
|
255
|
+
break
|
|
233
256
|
# If an instance's attribute name is given
|
|
234
257
|
if attr:
|
|
235
258
|
# If the attribute belongs to the new value
|
|
@@ -240,6 +263,10 @@ class Pointer(Generic[PT]):
|
|
|
240
263
|
else:
|
|
241
264
|
# Raise an "AttributeError"
|
|
242
265
|
raise AttributeError(f"\"{attr}\" is not an attribute of \"{self._value}\"")
|
|
266
|
+
# Else (value not referenced)
|
|
267
|
+
else:
|
|
268
|
+
# Raise a "NameError"
|
|
269
|
+
raise NameError(f"No reference is pointing to given value \"{self._value}\"")
|
|
243
270
|
|
|
244
271
|
# Get references
|
|
245
272
|
def get_refs(self)->tuple[str]:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{memorymanagement-1.4.2 → memorymanagement-1.4.4}/memorymanagement.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|