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.
- {python_plugins-0.1.3 → python_plugins-0.1.4}/CHANGES.rst +8 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/PKG-INFO +1 -1
- {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/usage.rst +9 -0
- python_plugins-0.1.4/src/python_plugins/__about__.py +1 -0
- python_plugins-0.1.4/src/python_plugins/models/update.py +33 -0
- python_plugins-0.1.4/src/python_plugins/utils/remove_pycache.py +13 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_sqlalchemy.py +6 -2
- python_plugins-0.1.4/tests/test_utils.py +8 -0
- python_plugins-0.1.3/src/python_plugins/__about__.py +0 -1
- {python_plugins-0.1.3 → python_plugins-0.1.4}/.github/workflows/release.yml +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/.gitignore +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/.readthedocs.yaml +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/LICENSE.rst +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/README.rst +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/Makefile +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/api.rst +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/changes.rst +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/conf.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/examples.rst +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/index.rst +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/make.bat +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/docs/requirements.txt +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/examples/README.rst +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/pyproject.toml +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/requirements/build.in +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/requirements/test.in +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/convert/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/convert/datetime_str.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/convert/xml.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/crypto/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/crypto/fernet.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/crypto/str_to_list.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/dumps/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/dumps/postgresql_dump.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/email/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/email/smtp.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/hashes/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/hashes/hash.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/jwt/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/jwt/jwt.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/data_mixin.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/primary_key_mixin.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/timestamp_mixin.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/user_minxin.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/process/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/process/python_venv_process.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/process/sub_process.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/random/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/random/random_str.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/__init__.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/conftest.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_crypto.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_email.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_jwt.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_process.py +0 -0
- {python_plugins-0.1.3 → python_plugins-0.1.4}/tests/test_random.py +0 -0
|
@@ -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
|
|
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)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/data_mixin.py
RENAMED
|
File without changes
|
{python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/primary_key_mixin.py
RENAMED
|
File without changes
|
{python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/timestamp_mixin.py
RENAMED
|
File without changes
|
{python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/models/mixins/user_minxin.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_plugins-0.1.3 → python_plugins-0.1.4}/src/python_plugins/process/python_venv_process.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|