python-plugins 0.1.3__tar.gz → 0.1.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.
Files changed (59) hide show
  1. {python_plugins-0.1.3 → python_plugins-0.1.4}/CHANGES.rst +8 -0
  2. {python_plugins-0.1.3 → python_plugins-0.1.4}/PKG-INFO +1 -1
  3. {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/usage.rst +9 -0
  4. python_plugins-0.1.4/src/python_plugins/__about__.py +1 -0
  5. python_plugins-0.1.4/src/python_plugins/models/update.py +33 -0
  6. python_plugins-0.1.4/src/python_plugins/utils/remove_pycache.py +13 -0
  7. {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_sqlalchemy.py +6 -2
  8. python_plugins-0.1.4/tests/test_utils.py +8 -0
  9. python_plugins-0.1.3/src/python_plugins/__about__.py +0 -1
  10. {python_plugins-0.1.3 → python_plugins-0.1.4}/.github/workflows/release.yml +0 -0
  11. {python_plugins-0.1.3 → python_plugins-0.1.4}/.gitignore +0 -0
  12. {python_plugins-0.1.3 → python_plugins-0.1.4}/.readthedocs.yaml +0 -0
  13. {python_plugins-0.1.3 → python_plugins-0.1.4}/LICENSE.rst +0 -0
  14. {python_plugins-0.1.3 → python_plugins-0.1.4}/README.rst +0 -0
  15. {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/Makefile +0 -0
  16. {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/api.rst +0 -0
  17. {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/changes.rst +0 -0
  18. {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/conf.py +0 -0
  19. {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/examples.rst +0 -0
  20. {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/index.rst +0 -0
  21. {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/make.bat +0 -0
  22. {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/requirements.txt +0 -0
  23. {python_plugins-0.1.3 → python_plugins-0.1.4}/examples/README.rst +0 -0
  24. {python_plugins-0.1.3 → python_plugins-0.1.4}/pyproject.toml +0 -0
  25. {python_plugins-0.1.3 → python_plugins-0.1.4}/requirements/build.in +0 -0
  26. {python_plugins-0.1.3 → python_plugins-0.1.4}/requirements/test.in +0 -0
  27. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/__init__.py +0 -0
  28. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/convert/__init__.py +0 -0
  29. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/convert/datetime_str.py +0 -0
  30. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/convert/xml.py +0 -0
  31. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/crypto/__init__.py +0 -0
  32. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/crypto/fernet.py +0 -0
  33. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/crypto/str_to_list.py +0 -0
  34. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/dumps/__init__.py +0 -0
  35. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/dumps/postgresql_dump.py +0 -0
  36. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/email/__init__.py +0 -0
  37. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/email/smtp.py +0 -0
  38. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/hashes/__init__.py +0 -0
  39. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/hashes/hash.py +0 -0
  40. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/jwt/__init__.py +0 -0
  41. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/jwt/jwt.py +0 -0
  42. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/__init__.py +0 -0
  43. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/__init__.py +0 -0
  44. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/data_mixin.py +0 -0
  45. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/primary_key_mixin.py +0 -0
  46. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/timestamp_mixin.py +0 -0
  47. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/user_minxin.py +0 -0
  48. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/process/__init__.py +0 -0
  49. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/process/python_venv_process.py +0 -0
  50. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/process/sub_process.py +0 -0
  51. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/random/__init__.py +0 -0
  52. {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/random/random_str.py +0 -0
  53. {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/__init__.py +0 -0
  54. {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/conftest.py +0 -0
  55. {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_crypto.py +0 -0
  56. {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_email.py +0 -0
  57. {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_jwt.py +0 -0
  58. {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_process.py +0 -0
  59. {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_random.py +0 -0
@@ -1,3 +1,11 @@
1
+ v0.1.4
2
+ ------
3
+
4
+ Released 2024-09-26
5
+
6
+ - remove_pycache
7
+ - models.update
8
+
1
9
  v0.1.3
2
10
  ------
3
11
 
@@ -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
@@ -50,3 +50,12 @@ mixins
50
50
 
51
51
  class User(PrimaryKeyMixin,UserMixin, TimestampMixin,db.models):
52
52
  pass
53
+
54
+ remove_pycache
55
+ =======================
56
+
57
+ .. code-block :: python
58
+
59
+ from python_plugins.utils.remove_pycache import remove_pycache
60
+
61
+ remove_pycache(".")
@@ -0,0 +1 @@
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
+
@@ -2,6 +2,7 @@ from sqlalchemy.orm import Mapped
2
2
  from sqlalchemy.orm import mapped_column
3
3
  from python_plugins.models.mixins import PrimaryKeyMixin
4
4
  from python_plugins.models.mixins import DataMixin
5
+ from python_plugins.models.mixins import TimestampMixin
5
6
  from sqlalchemy.orm import DeclarativeBase
6
7
  from sqlalchemy.schema import CreateTable
7
8
 
@@ -12,14 +13,17 @@ class Base(DeclarativeBase):
12
13
  pass
13
14
 
14
15
 
15
- class Demo(PrimaryKeyMixin, DataMixin, Base):
16
+ class Demo(PrimaryKeyMixin, DataMixin, TimestampMixin,Base):
16
17
  __tablename__ = "demo"
17
18
 
18
19
 
19
- def test_info():
20
+ def test_createtable():
20
21
 
21
22
  assert Demo.__table__.name == "demo"
22
23
  stmt = CreateTable(Demo.__table__)
23
24
  # print(stmt)
24
25
  assert "id INTEGER" in str(stmt)
26
+ assert "PRIMARY KEY" in str(stmt)
25
27
  assert "data JSON" in str(stmt)
28
+ assert "created_at DATETIME" in str(stmt)
29
+ assert "updated_at DATETIME" in str(stmt)
@@ -0,0 +1,8 @@
1
+ import pytest
2
+
3
+ from python_plugins.utils.remove_pycache import remove_pycache
4
+
5
+ @pytest.mark.skip
6
+ def test_remove_pycache():
7
+ remove_pycache("./tests")
8
+
@@ -1 +0,0 @@
1
- __version__ = "0.1.3"