python-plugins 0.1.1__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 +1 @@
1
- __version__ = "0.1.1"
1
+ __version__ = "0.1.2"
File without changes
@@ -0,0 +1,4 @@
1
+ from .primary_key_mixin import PrimaryKeyMixin
2
+ from .timestamp_mixin import TimestampMixin, CreateTimestampMixin, UpdateTimestampMixin
3
+ from .data_mixin import DataMixin
4
+ from .user_minxin import UserMixin
@@ -0,0 +1,15 @@
1
+ from sqlalchemy.orm import mapped_column
2
+ from sqlalchemy.types import JSON
3
+
4
+
5
+ class DataMixin:
6
+ data = mapped_column(type_=JSON)
7
+
8
+ def update_data(self, data: dict):
9
+ if self.data is None:
10
+ new_data = {}
11
+ else:
12
+ new_data = dict(self.data)
13
+ for k in data:
14
+ new_data[k] = data[k]
15
+ self.data = new_data
@@ -0,0 +1,6 @@
1
+ from sqlalchemy.orm import Mapped
2
+ from sqlalchemy.orm import mapped_column
3
+
4
+
5
+ class PrimaryKeyMixin:
6
+ id: Mapped[int] = mapped_column(primary_key=True)
@@ -0,0 +1,20 @@
1
+ from datetime import datetime
2
+ from sqlalchemy.orm import Mapped
3
+ from sqlalchemy.orm import mapped_column
4
+
5
+
6
+ class TimestampMixin:
7
+ created_at: Mapped[datetime] = mapped_column(default=datetime.now)
8
+ updated_at: Mapped[datetime] = mapped_column(
9
+ default=datetime.now, onupdate=datetime.now
10
+ )
11
+
12
+
13
+ class CreateTimestampMixin:
14
+ created_at: Mapped[datetime] = mapped_column(default=datetime.now)
15
+
16
+
17
+ class UpdateTimestampMixin:
18
+ updated_at: Mapped[datetime] = mapped_column(
19
+ default=datetime.now, onupdate=datetime.now
20
+ )
@@ -0,0 +1,26 @@
1
+ class UserMixin:
2
+ @property
3
+ def is_active(self):
4
+ return self.isactive
5
+
6
+ @property
7
+ def is_authenticated(self):
8
+ return True
9
+
10
+ @property
11
+ def is_anonymous(self):
12
+ return False
13
+
14
+ def get_id(self):
15
+ return self.id
16
+
17
+ def __eq__(self, other):
18
+ if isinstance(other, self.__class__):
19
+ return self.get_id() == other.get_id()
20
+ return NotImplemented
21
+
22
+ def __ne__(self, other):
23
+ equal = self.__eq__(other)
24
+ if equal is NotImplemented:
25
+ return NotImplemented
26
+ return not equal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: python-plugins
3
- Version: 0.1.1
3
+ Version: 0.1.2
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
@@ -44,6 +44,8 @@ Provides-Extra: pillow
44
44
  Requires-Dist: pillow; extra == 'pillow'
45
45
  Provides-Extra: qrcode
46
46
  Requires-Dist: qrcode; extra == 'qrcode'
47
+ Provides-Extra: sqlalchemy
48
+ Requires-Dist: sqlalchemy; extra == 'sqlalchemy'
47
49
  Description-Content-Type: text/x-rst
48
50
 
49
51
  python-plugins
@@ -0,0 +1,14 @@
1
+ python_plugins/__about__.py,sha256=YvuYzWnKtqBb-IqG8HAu-nhIYAsgj9Vmc_b9o7vO-js,22
2
+ python_plugins/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
3
+ python_plugins/email/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ python_plugins/email/smtp.py,sha256=weSfLVPzROFqwlxDaVhjem522NVEp31lc6PFkbZE1ok,854
5
+ python_plugins/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ python_plugins/models/mixins/__init__.py,sha256=s1S9jtS8W3xbvbshFkh4WvJBqbjScSvN27Chn8_D_Pw,204
7
+ python_plugins/models/mixins/data_mixin.py,sha256=HCc1uvF6_O4yjK38uWAsqysEedLWgc7wtds3NjQTMZ8,366
8
+ python_plugins/models/mixins/primary_key_mixin.py,sha256=QUO-7ZmYtAMMi7ReRQDYV0uwQCnU9dvl6g6GHitYtlA,154
9
+ python_plugins/models/mixins/timestamp_mixin.py,sha256=u9rIu0IrzdCRRbnMk4IN4nTlNNiVPB8yPnTcHjQC1KU,547
10
+ python_plugins/models/mixins/user_minxin.py,sha256=D-N45bunicBuuwKs--s_tyDxxLC3mkxV9Tva8JAhsko,579
11
+ python_plugins-0.1.2.dist-info/METADATA,sha256=uDCEUZwFeovFz8pcWx08SpG-WTn6TNwiw1SeDVl_a3Y,2754
12
+ python_plugins-0.1.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
13
+ python_plugins-0.1.2.dist-info/licenses/LICENSE.rst,sha256=d9ee1DxacJqITSYaORZy85rWGNZyZbDNv_r-lY2RQ9s,1099
14
+ python_plugins-0.1.2.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- python_plugins/__about__.py,sha256=rnObPjuBcEStqSO0S6gsdS_ot8ITOQjVj_-P1LUUYpg,22
2
- python_plugins/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
3
- python_plugins/email/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- python_plugins/email/smtp.py,sha256=weSfLVPzROFqwlxDaVhjem522NVEp31lc6PFkbZE1ok,854
5
- python_plugins-0.1.1.dist-info/METADATA,sha256=qo6G2DG_qFVzqexeVu1o00KmqdGQBRJjbrioDEHQQeo,2678
6
- python_plugins-0.1.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
7
- python_plugins-0.1.1.dist-info/licenses/LICENSE.rst,sha256=d9ee1DxacJqITSYaORZy85rWGNZyZbDNv_r-lY2RQ9s,1099
8
- python_plugins-0.1.1.dist-info/RECORD,,