memorymanagement 1.4.2__tar.gz → 1.4.3__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.3}/PKG-INFO +1 -1
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement/pointers/core.py +34 -16
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement.egg-info/PKG-INFO +1 -1
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/setup.cfg +1 -1
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/LICENSE +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/README.md +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement/__init__.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement/cleaning/__init__.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement/cleaning/core.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement/pointers/__init__.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement/pointers/decorators.py +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement.egg-info/SOURCES.txt +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement.egg-info/dependency_links.txt +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/memorymanagement.egg-info/top_level.txt +0 -0
- {memorymanagement-1.4.2 → memorymanagement-1.4.3}/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,7 +132,19 @@ 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 (only value)
|
|
137
148
|
else:
|
|
138
149
|
# Store every reference pointing to the given value
|
|
139
150
|
name=[key for key,v in vars_dict.items() if v is value]
|
|
@@ -145,6 +156,13 @@ class Pointer(Generic[PT]):
|
|
|
145
156
|
if self._name==None:
|
|
146
157
|
# Raise a "NameError"
|
|
147
158
|
raise NameError(f"No reference is pointing to given value \"{self._value}\"")
|
|
159
|
+
# Set argument "value" as the pointer's value
|
|
160
|
+
self._value=value
|
|
161
|
+
|
|
162
|
+
# If there is an instance's attribute to point to and it doesn't belong to the given value
|
|
163
|
+
if attr and attr not in dir(value):
|
|
164
|
+
# Raise an "AttributeError"
|
|
165
|
+
raise AttributeError(f"\"{attr}\" is not an attribute of \"{value}\"")
|
|
148
166
|
|
|
149
167
|
# Point to
|
|
150
168
|
def point_to(self,value=None,reference:str|None=None,*,attr:str|None=None):
|
|
@@ -153,15 +171,15 @@ class Pointer(Generic[PT]):
|
|
|
153
171
|
|
|
154
172
|
Arguments
|
|
155
173
|
---------
|
|
156
|
-
reference : `str`|`None`, Optional
|
|
157
|
-
Reference pointing to the desired value. If wanted class attribute, introduce the reference for the class instance.
|
|
158
174
|
value : `Any`|`None`, Optional
|
|
159
175
|
Value to point to. If wanted class attribute, introduce just the class object.
|
|
176
|
+
reference : `str`|`None`, Optional
|
|
177
|
+
Reference pointing to the desired value. If wanted class attribute, introduce the reference for the class instance.
|
|
160
178
|
attr : `str`|`None`, Optional
|
|
161
179
|
Attribute of the class if class object was passed through `reference` or `value`.
|
|
162
180
|
"""
|
|
163
181
|
# If no reference or value is given
|
|
164
|
-
if not
|
|
182
|
+
if not value and not reference:
|
|
165
183
|
# If an instance's attribute name is given
|
|
166
184
|
if attr:
|
|
167
185
|
# If the attribute belongs to the pointer's value
|
|
@@ -220,8 +238,8 @@ class Pointer(Generic[PT]):
|
|
|
220
238
|
else:
|
|
221
239
|
# Raise a "NameError"
|
|
222
240
|
raise NameError(f"Name \"{reference}\" is not defined")
|
|
223
|
-
# Else
|
|
224
|
-
|
|
241
|
+
# Else (only value)
|
|
242
|
+
else:
|
|
225
243
|
# Store the given value and its references into their corresponding hidden attributes
|
|
226
244
|
self._name,self._value=[key for key,v in self._vars_dict.items() if v is value],value
|
|
227
245
|
# Modify the "_name" hidden attribute to be a string or "None"
|
|
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.3}/memorymanagement.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|