memorymanagement 1.4.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memorymanagement
3
- Version: 1.4.3
3
+ Version: 1.4.4
4
4
  Summary: Adds support for memory management
5
5
  Home-page: https://github.com/Ricardo-Werner-Rivas/memorymanagement/tree/PyPI
6
6
  Author: Ricardo Werner Rivas
@@ -144,20 +144,25 @@ class Pointer(Generic[PT]):
144
144
  else:
145
145
  # Raise a "NameError"
146
146
  raise NameError(f"Name \"{reference}\" is not defined")
147
- # Else (only value)
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)
148
158
  else:
149
- # Store every reference pointing to the given value
150
- name=[key for key,v in vars_dict.items() if v is value]
151
- # Set to "None" if no reference was found
152
- name=name[0] if len(name)!=0 else None
153
- # Store the reference in the hidden attribute "_name"
154
- self._name=name
155
- # If there is no reference
156
- if self._name==None:
157
159
  # Raise a "NameError"
158
- raise NameError(f"No reference is pointing to given value \"{self._value}\"")
160
+ raise NameError(f"No reference is pointing to given value \"{value}\" ({value.__class__.__name__})")
161
+
159
162
  # Set argument "value" as the pointer's value
160
163
  self._value=value
164
+ # Store the reference in the hidden attribute "_name"
165
+ self._name=name
161
166
 
162
167
  # If there is an instance's attribute to point to and it doesn't belong to the given value
163
168
  if attr and attr not in dir(value):
@@ -238,16 +243,16 @@ class Pointer(Generic[PT]):
238
243
  else:
239
244
  # Raise a "NameError"
240
245
  raise NameError(f"Name \"{reference}\" is not defined")
241
- # Else (only value)
242
- else:
243
- # Store the given value and its references into their corresponding hidden attributes
244
- self._name,self._value=[key for key,v in self._vars_dict.items() if v is value],value
245
- # Modify the "_name" hidden attribute to be a string or "None"
246
- self._name=self._name[0] if len(self._name)!=0 else None
247
- # If no reference was found
248
- if self._name==None:
249
- # Raise a "NameError"
250
- raise NameError(f"No reference is pointing to given value \"{self._value}\"")
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
251
256
  # If an instance's attribute name is given
252
257
  if attr:
253
258
  # If the attribute belongs to the new value
@@ -258,6 +263,10 @@ class Pointer(Generic[PT]):
258
263
  else:
259
264
  # Raise an "AttributeError"
260
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}\"")
261
270
 
262
271
  # Get references
263
272
  def get_refs(self)->tuple[str]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memorymanagement
3
- Version: 1.4.3
3
+ Version: 1.4.4
4
4
  Summary: Adds support for memory management
5
5
  Home-page: https://github.com/Ricardo-Werner-Rivas/memorymanagement/tree/PyPI
6
6
  Author: Ricardo Werner Rivas
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = memorymanagement
3
- version = 1.4.3
3
+ version = 1.4.4
4
4
  author = Ricardo Werner Rivas
5
5
  author_email = ricardowernerrivas@gmail.com
6
6
  description = Adds support for memory management