python-plugins 0.1.3__py3-none-any.whl → 0.1.4__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 +1 @@
1
- __version__ = "0.1.3"
1
+ __version__ = "0.1.4"
@@ -0,0 +1,33 @@
1
+ def update_obj(db, old_obj, new_data: dict, NewClass, force=None):
2
+ """insert or update object
3
+
4
+ :param db: sqlalchemy db
5
+ :param old_obj: old object
6
+ :param new_data: new dict
7
+ :param NewClass: object class
8
+ :param force: update= update old object with new attribute
9
+ """
10
+ # 1. old is not exist
11
+ if old_obj is None:
12
+ new_obj = NewClass()
13
+ for k in new_data:
14
+ if hasattr(new_obj, k):
15
+ setattr(new_obj, k, new_data.get(k))
16
+ db.session.add(new_obj)
17
+ db.session.commit()
18
+ print(f"{new_obj} inserted")
19
+ return
20
+
21
+ # 2. old is exist
22
+ match force:
23
+ case None:
24
+ print(f"{old_obj} exists")
25
+ case "update":
26
+ # update old
27
+ for k in new_data:
28
+ if hasattr(old_obj, k):
29
+ setattr(old_obj, k, new_data.get(k))
30
+ db.session.commit()
31
+ print(f"{old_obj} updated")
32
+ case _:
33
+ raise Exception
@@ -0,0 +1,13 @@
1
+ import os
2
+ import shutil
3
+
4
+ def remove_pycache(dir_path):
5
+ for root, dirs, files in os.walk(dir_path):
6
+ if "venv" in root or "git" in root:
7
+ continue
8
+ for dir in dirs:
9
+ if dir == "__pycache__":
10
+ pycache_path = os.path.join(root, dir)
11
+ print(f"Removing {pycache_path}")
12
+ shutil.rmtree(pycache_path)
13
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: python-plugins
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: A collection of Python functions and classes.
5
5
  Project-URL: Documentation, https://python-plugins.readthedocs.io
6
6
  Project-URL: Source, https://github.com/ojso/python-plugins
@@ -1,4 +1,4 @@
1
- python_plugins/__about__.py,sha256=XEqb2aiIn8fzGE68Mph4ck1FtQqsR_am0wRWvrYPffQ,22
1
+ python_plugins/__about__.py,sha256=Wzf5T3NBDfhQoTnhnRNHSlAsE0XMqbclXG-M81Vas70,22
2
2
  python_plugins/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
3
3
  python_plugins/convert/__init__.py,sha256=UwzPhcQLaHEvcssbrcCymWujBV_BOmfYCIJxGPyJdbY,79
4
4
  python_plugins/convert/datetime_str.py,sha256=bmC9d1W7XKA1ED9XO9reUiUyfQcM_BqGoGyOF21RW9A,282
@@ -15,6 +15,7 @@ python_plugins/hashes/hash.py,sha256=uSF3ohZRD7b2VAIvjjpTWC0SlY7QsFhsFZUejINrRGU
15
15
  python_plugins/jwt/__init__.py,sha256=GS27VK4uk1FXsmju5xpHu0p4FNSwW-tkeJ3hCSaW1rY,40
16
16
  python_plugins/jwt/jwt.py,sha256=g1wfg6euVUbaF5CvAWvu29U_KQKd1u2RvfAdkcOJbNA,908
17
17
  python_plugins/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ python_plugins/models/update.py,sha256=cIwhR0iKkB7cVx7km_oA9ya97MSkJlLPb8pZWaEePmE,991
18
19
  python_plugins/models/mixins/__init__.py,sha256=s1S9jtS8W3xbvbshFkh4WvJBqbjScSvN27Chn8_D_Pw,204
19
20
  python_plugins/models/mixins/data_mixin.py,sha256=HCc1uvF6_O4yjK38uWAsqysEedLWgc7wtds3NjQTMZ8,366
20
21
  python_plugins/models/mixins/primary_key_mixin.py,sha256=QUO-7ZmYtAMMi7ReRQDYV0uwQCnU9dvl6g6GHitYtlA,154
@@ -25,7 +26,8 @@ python_plugins/process/python_venv_process.py,sha256=yRgaKfPQ-TC_Kn2tuDqoTJZ__21
25
26
  python_plugins/process/sub_process.py,sha256=OwjPb2-xEnE6fiXVL0Jv5R9aE_6cmr_1zcRAmCOykcc,317
26
27
  python_plugins/random/__init__.py,sha256=V0qSIG6LiAkOK1xT6r6yezgKMMWh6ynoSe6Pt_yxG3I,163
27
28
  python_plugins/random/random_str.py,sha256=d3y96cQmiKfwtxvT0fTlOdq9gclbMF2_g_6ud__2ueE,819
28
- python_plugins-0.1.3.dist-info/METADATA,sha256=UNVm572llNb-iQeWrRWyPZlK6K3XOpm14v4lq_RAEFc,2811
29
- python_plugins-0.1.3.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
30
- python_plugins-0.1.3.dist-info/licenses/LICENSE.rst,sha256=d9ee1DxacJqITSYaORZy85rWGNZyZbDNv_r-lY2RQ9s,1099
31
- python_plugins-0.1.3.dist-info/RECORD,,
29
+ python_plugins/utils/remove_pycache.py,sha256=aKCkmSRVWioV6PZmjJOzXUtMUsewTbWFEgL2OUPF26I,380
30
+ python_plugins-0.1.4.dist-info/METADATA,sha256=IhpDIx3ozu1GRH6PPKloIOenaIVacjxrrbfqmDcDTZY,2811
31
+ python_plugins-0.1.4.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
32
+ python_plugins-0.1.4.dist-info/licenses/LICENSE.rst,sha256=d9ee1DxacJqITSYaORZy85rWGNZyZbDNv_r-lY2RQ9s,1099
33
+ python_plugins-0.1.4.dist-info/RECORD,,