python-ubercode-utils 2.0.4__py3-none-any.whl → 2.0.6__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.1
2
2
  Name: python-ubercode-utils
3
- Version: 2.0.4
3
+ Version: 2.0.6
4
4
  Summary: Core python utilities for all apps
5
5
  Home-page: https://github.com/sstacha/python-ubercode-utils
6
6
  Author: Steve Stacha
@@ -4,11 +4,11 @@ ubercode/utils/convert.py,sha256=INxAIlIkwTeHSdVpqm8R_N5MzrSrjY9CduioHipu39g,113
4
4
  ubercode/utils/cursor.py,sha256=zHqbmUavCF0l7ck_Tu4PfgSzRO762ULKHYsnqa3r0uY,1118
5
5
  ubercode/utils/data.py,sha256=DStj9BAXPSPvQRZwfEQVYt19EoMavyNFt11U8ZnhagE,4364
6
6
  ubercode/utils/dataframe.py,sha256=3AYoZGZB7wtN5brBDfRgnuIaEubhRrSc7qx8hi_vaaE,1616
7
- ubercode/utils/environment.py,sha256=97uYs0zGBkk7TfKuml6Th27kpdtYX_ILwfZTQW3Xac8,15818
7
+ ubercode/utils/environment.py,sha256=G2HaRxeVGZBO6nGqO3iXeLcA8zAfLRUO6LXVyeMiNBs,15822
8
8
  ubercode/utils/logging.py,sha256=s4yIJWHo9MVO4oSk5IF3z6XTk-FOuyEiKnPFkiza3h4,9204
9
- ubercode/utils/urls.py,sha256=N2B0s849WRpV_JWc20hBb4129UZZkeWEcPjfd9rggrY,13399
10
- python_ubercode_utils-2.0.4.dist-info/LICENSE,sha256=lch0WEJaqJY3C5aCYSr0u6Gw0set96a2fp9ZWJRYuR8,1069
11
- python_ubercode_utils-2.0.4.dist-info/METADATA,sha256=L5_YcnH89oIyTP_EeOLQR-AycJUR4YLHvEly5_RSRV0,1225
12
- python_ubercode_utils-2.0.4.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
13
- python_ubercode_utils-2.0.4.dist-info/top_level.txt,sha256=5BojzbvNCpPkFXcVQVr7cfovhbYQYAlMKgiHSMgi7VU,9
14
- python_ubercode_utils-2.0.4.dist-info/RECORD,,
9
+ ubercode/utils/urls.py,sha256=dkAHH-ZOXkqueKor94fCmwUz6I4KnvAM_XcW8k2XjaY,14507
10
+ python_ubercode_utils-2.0.6.dist-info/LICENSE,sha256=lch0WEJaqJY3C5aCYSr0u6Gw0set96a2fp9ZWJRYuR8,1069
11
+ python_ubercode_utils-2.0.6.dist-info/METADATA,sha256=LVm8lXskkDpU6X_sgkZ6HLvTvTTrYcrULJZ_ae6diNs,1225
12
+ python_ubercode_utils-2.0.6.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
13
+ python_ubercode_utils-2.0.6.dist-info/top_level.txt,sha256=5BojzbvNCpPkFXcVQVr7cfovhbYQYAlMKgiHSMgi7VU,9
14
+ python_ubercode_utils-2.0.6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.46.3)
2
+ Generator: bdist_wheel (0.44.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -199,7 +199,7 @@ class Environment:
199
199
  _log_from_value = 'None'
200
200
  _log_to_value = str(v)
201
201
  # we may be setting up a completely new database from scratch so create if it doesn't exist
202
- if not db_dict[db_parts[1]]:
202
+ if not db_dict.get(db_parts[1]):
203
203
  self._logger.debug(f'database {db_parts[0]}[{db_parts[1]}] was not found; creating...')
204
204
  db_dict[db_parts[1]] = {}
205
205
  # we now have db dict; we may not have a property already defined; if not we want to add it
ubercode/utils/urls.py CHANGED
@@ -290,10 +290,34 @@ class DjUrl:
290
290
  elif len(hoststr) > 0:
291
291
  self.host = hoststr
292
292
 
293
+ #
294
+ def from_dict(self, properties_dict: dict):
295
+ """
296
+ overrides instance properties with dictionary values
297
+ NOTE: rule is that we expect the instance propery to be attribute uppercased
298
+ EX: self.name = properties_dict[self.name.upper()]
299
+
300
+ :param properties_dict: dictionary values
301
+ :return: this instance for chaining. ex: x = DjUrl().from_dict({"ENGINE": "test"})
302
+ """
303
+ if isinstance(properties_dict, dict):
304
+ for attr, value in vars(DjUrl).items():
305
+ if not attr.startswith('__') and not callable(value) and not attr.startswith('_'):
306
+ setattr(self, attr, properties_dict.get(attr.upper(), value))
307
+ return self
308
+
293
309
  def to_dict(self) -> dict:
310
+ """
311
+ converts instance properties to dictionary values
312
+ NOTE: does not convert None values
313
+
314
+ :return: dict of values in upper case for replacement in django databases settings
315
+ """
294
316
  dct = {}
295
- for attr, value in vars(self).items():
296
- dct[attr.upper()] = value
317
+ for attr, value in vars(DjUrl).items():
318
+ if not attr.startswith('__') and not callable(value) and not attr.startswith('_'):
319
+ if getattr(self, attr) is not None:
320
+ dct[attr.upper()] = getattr(self, attr)
297
321
  return dct
298
322
 
299
323
  def __str__(self) -> str: