cloud-python-vars 0.1.0__py3-none-any.whl → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloud-python-vars
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: To manage and create raw Python variables on cloud servers.
5
5
  Author-email: ThatOnePythonDev <khakhang2h5e@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -16,7 +16,12 @@ Dynamic: license-file
16
16
 
17
17
  A Python module for managing Cloud Variables.
18
18
 
19
+ ## IMPORTANT NOTES
20
+
21
+ Since this module is built upon the package upstash-redis, you **MUST** visit the website right [here](https://console.upstash.com/redis) to create tokens and the link that are **nessecary** for the following examples.
22
+
19
23
  ## Examples:
24
+
20
25
  ### Example 1 for the `CloudVar` class.
21
26
 
22
27
  ```python
@@ -56,6 +61,7 @@ print(cloudvar.items()) # {}
56
61
  ```
57
62
 
58
63
  ### Example 2 for the class `AsyncCloudVar`.
64
+
59
65
  ```python
60
66
  import cloud_variables as cv
61
67
  import asyncio
@@ -67,29 +73,29 @@ async def main(): # Use asynchronous functions for full functionality access.
67
73
 
68
74
  # Basic assignment
69
75
  async_cloudvar["string"] = "Hello, World!"
70
-
76
+
71
77
  # Retrieving values
72
78
  print(async_cloudvar["string"]) # 'Hello, World!'
73
-
79
+
74
80
  # Advanced mutable objects
75
81
  async_cloudvar["list"] = [1, 2, 3]
76
82
  async_cloudvar["list"].append(4)
77
-
83
+
78
84
  print(async_cloudvar["list"]) # [1, 2, 3, 4]
79
-
85
+
80
86
  # Deleting and popping items
81
87
  async_cloudvar["key1"] = "value1"
82
88
  async_cloudvar["key2"] = "value2"
83
-
89
+
84
90
  del async_cloudvar["key1"] # Deleting keys.
85
91
  value = await async_cloudvar.pop("key2") # Popping keys
86
92
  print(value) # 'value2'
87
-
93
+
88
94
  # Some more methods
89
-
95
+
90
96
  # Retrieving Python key-value pairs as dictionaries
91
97
  print(await async_cloudvar.items()) # {'string': 'Hello, World!', 'list': [1, 2, 3, 4]}
92
-
98
+
93
99
  # Clearing everything
94
100
  await async_cloudvar.clear()
95
101
  print(await async_cloudvar.items()) # {}
@@ -100,6 +106,7 @@ asyncio.run(main())
100
106
  ## Installation
101
107
 
102
108
  You can easily install the module by typing the command:
109
+
103
110
  ```bash
104
111
  pip install cloud-python-vars
105
112
  ```
@@ -0,0 +1,6 @@
1
+ cloud_variables.py,sha256=X2YBZJUtCvx3DkCH6dJ3ZlIPzcQJEKIzbUXPmPEb1fc,11291
2
+ cloud_python_vars-0.1.2.dist-info/licenses/LICENSE,sha256=QrYZJWmrewKHOtQwd1ymTUDpPzhnXt9Fhv6PGf-JfGs,35788
3
+ cloud_python_vars-0.1.2.dist-info/METADATA,sha256=B1H1ZIj-YM5Ypea998mHPwXN8h9MlVM7tNW2dREixm4,3088
4
+ cloud_python_vars-0.1.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
+ cloud_python_vars-0.1.2.dist-info/top_level.txt,sha256=DxTkZ9m7oYGS873O2K7iiP6cP4t0LRqo9jL1wn-Voog,16
6
+ cloud_python_vars-0.1.2.dist-info/RECORD,,
cloud_variables.py CHANGED
@@ -160,7 +160,7 @@ class CloudVar(redis.Redis):
160
160
 
161
161
  super().__init__(url, token, rest_encoding, rest_retries, rest_retry_interval, allow_telemetry, read_your_writes,)
162
162
 
163
- self.__data: dict[str, CloudProxy] = {k: v for k, v in self.items().items()}
163
+ self.__data: dict[str, CloudProxy] = {k: CloudProxy(v) for k, v in self.items().items()}
164
164
 
165
165
  self.__thread: threading.Thread = threading.Thread(target=self.__loop)
166
166
  self.__thread.start()
@@ -171,8 +171,8 @@ class CloudVar(redis.Redis):
171
171
  for k, v in self.__data.copy().items():
172
172
  self.set(k, repr(v))
173
173
  time.sleep(0.1)
174
- except:
175
- pass
174
+ except Exception as e:
175
+ print(e.__traceback__)
176
176
 
177
177
  def __setitem__(self, key: str, value: Any) -> None:
178
178
  """
@@ -219,6 +219,9 @@ class CloudVar(redis.Redis):
219
219
  values: list[Any] = [self[key] for key in keys]
220
220
  self.delete(*keys)
221
221
 
222
+ for key in keys:
223
+ del self.__data[key]
224
+
222
225
  return tuple(values)
223
226
 
224
227
  def clear(self) -> None:
@@ -229,6 +232,7 @@ class CloudVar(redis.Redis):
229
232
 
230
233
  all_keys: list[str] = self.keys(r"[\s\S]*")
231
234
  self.delete(*all_keys)
235
+ self.__data.clear()
232
236
 
233
237
  def items(self) -> dict[str, Any]:
234
238
  """
@@ -283,7 +287,7 @@ class AsyncCloudVar(redis.AsyncRedis):
283
287
  def start(self) -> None:
284
288
  """Starts the instance's process."""
285
289
 
286
- async def task() -> Never | None:
290
+ async def task() -> None:
287
291
  self.__data = {k: v for k, v in (await self.items()).items()}
288
292
 
289
293
  try:
@@ -291,8 +295,8 @@ class AsyncCloudVar(redis.AsyncRedis):
291
295
  for k, v in self.__data.copy().items():
292
296
  await self.set(k, repr(v))
293
297
  await asyncio.sleep(0.1)
294
- except:
295
- pass
298
+ except Exception as e:
299
+ print(e.__traceback__)
296
300
 
297
301
  asyncio.create_task(task())
298
302
 
@@ -341,6 +345,9 @@ class AsyncCloudVar(redis.AsyncRedis):
341
345
  values: list[Any] = [self[key] for key in keys]
342
346
  await self.delete(*keys)
343
347
 
348
+ for key in keys:
349
+ del self.__data[key]
350
+
344
351
  return tuple(values)
345
352
 
346
353
  async def clear(self) -> None:
@@ -352,6 +359,8 @@ class AsyncCloudVar(redis.AsyncRedis):
352
359
  all_keys: list[str] = await self.keys(r"[\s\S]*")
353
360
  await self.delete(*all_keys)
354
361
 
362
+ self.__data.clear()
363
+
355
364
  async def items(self) -> dict[str, Any]:
356
365
  """
357
366
  Returns a dictionary of key-value pairs on the client.
@@ -361,4 +370,4 @@ class AsyncCloudVar(redis.AsyncRedis):
361
370
  :returns: The key-value pairs from the client.
362
371
  """
363
372
 
364
- return {k: self.get(k) for k in await self.keys(r"[\s\S]*") if self.get(k)}
373
+ return {k: await self.get(k) for k in await self.keys(r"[\s\S]*") if await self.get(k)}
@@ -1,6 +0,0 @@
1
- cloud_variables.py,sha256=ui99sO77W4X7JxfhCpwMu2fub5YV4g5lXPggP5thTL4,11017
2
- cloud_python_vars-0.1.0.dist-info/licenses/LICENSE,sha256=QrYZJWmrewKHOtQwd1ymTUDpPzhnXt9Fhv6PGf-JfGs,35788
3
- cloud_python_vars-0.1.0.dist-info/METADATA,sha256=xTlDt5P8Lf5VCSWeNJ1y18QveGk740QZ1sf42yaunU4,2870
4
- cloud_python_vars-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
- cloud_python_vars-0.1.0.dist-info/top_level.txt,sha256=DxTkZ9m7oYGS873O2K7iiP6cP4t0LRqo9jL1wn-Voog,16
6
- cloud_python_vars-0.1.0.dist-info/RECORD,,