python-plugins 0.1.0__tar.gz → 0.1.2__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.2/CHANGES.rst +20 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/PKG-INFO +9 -1
- {python_plugins-0.1.0 → python_plugins-0.1.2}/docs/conf.py +2 -3
- python_plugins-0.1.2/docs/usage.rst +52 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/pyproject.toml +6 -0
- python_plugins-0.1.2/requirements/test.in +2 -0
- python_plugins-0.1.2/src/python_plugins/__about__.py +1 -0
- python_plugins-0.1.2/src/python_plugins/email/__init__.py +0 -0
- python_plugins-0.1.2/src/python_plugins/email/smtp.py +34 -0
- python_plugins-0.1.2/src/python_plugins/models/__init__.py +0 -0
- python_plugins-0.1.2/src/python_plugins/models/mixins/__init__.py +4 -0
- python_plugins-0.1.2/src/python_plugins/models/mixins/data_mixin.py +15 -0
- python_plugins-0.1.2/src/python_plugins/models/mixins/primary_key_mixin.py +6 -0
- python_plugins-0.1.2/src/python_plugins/models/mixins/timestamp_mixin.py +20 -0
- python_plugins-0.1.2/src/python_plugins/models/mixins/user_minxin.py +26 -0
- python_plugins-0.1.2/tests/conftest.py +9 -0
- python_plugins-0.1.2/tests/test_email.py +25 -0
- python_plugins-0.1.0/CHANGES.rst +0 -6
- python_plugins-0.1.0/docs/usage.rst +0 -14
- python_plugins-0.1.0/src/python_plugins/__about__.py +0 -1
- {python_plugins-0.1.0 → python_plugins-0.1.2}/.github/workflows/release.yml +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/.gitignore +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/.readthedocs.yaml +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/LICENSE.rst +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/README.rst +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/docs/Makefile +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/docs/api.rst +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/docs/changes.rst +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/docs/examples.rst +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/docs/index.rst +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/docs/make.bat +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/docs/requirements.txt +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/examples/README.rst +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/requirements/build.in +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/src/python_plugins/__init__.py +0 -0
- {python_plugins-0.1.0 → python_plugins-0.1.2}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: python-plugins
|
|
3
|
-
Version: 0.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
|
|
@@ -38,6 +38,14 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
38
38
|
Classifier: Programming Language :: Python :: 3.11
|
|
39
39
|
Classifier: Topic :: Software Development :: Build Tools
|
|
40
40
|
Requires-Python: >=3.10
|
|
41
|
+
Provides-Extra: cryptography
|
|
42
|
+
Requires-Dist: cryptography; extra == 'cryptography'
|
|
43
|
+
Provides-Extra: pillow
|
|
44
|
+
Requires-Dist: pillow; extra == 'pillow'
|
|
45
|
+
Provides-Extra: qrcode
|
|
46
|
+
Requires-Dist: qrcode; extra == 'qrcode'
|
|
47
|
+
Provides-Extra: sqlalchemy
|
|
48
|
+
Requires-Dist: sqlalchemy; extra == 'sqlalchemy'
|
|
41
49
|
Description-Content-Type: text/x-rst
|
|
42
50
|
|
|
43
51
|
python-plugins
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
8
8
|
|
|
9
9
|
project = 'python-plugins'
|
|
10
|
-
copyright = '2024,
|
|
11
|
-
author = '
|
|
10
|
+
copyright = '2024, David Hua'
|
|
11
|
+
author = 'David Hua'
|
|
12
12
|
|
|
13
13
|
# -- General configuration ---------------------------------------------------
|
|
14
14
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
@@ -27,5 +27,4 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
|
|
27
27
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
28
28
|
|
|
29
29
|
html_theme = 'classic'
|
|
30
|
-
html_static_path = ['_static']
|
|
31
30
|
html_title = "python-plugins Documentation"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
=====
|
|
2
|
+
Usage
|
|
3
|
+
=====
|
|
4
|
+
|
|
5
|
+
.. _installation:
|
|
6
|
+
|
|
7
|
+
Installation
|
|
8
|
+
==============
|
|
9
|
+
|
|
10
|
+
Install and update using pip:
|
|
11
|
+
|
|
12
|
+
.. code-block:: console
|
|
13
|
+
|
|
14
|
+
(.venv) $ pip install -U python-plugins
|
|
15
|
+
|
|
16
|
+
email
|
|
17
|
+
======
|
|
18
|
+
|
|
19
|
+
.. code-block:: python
|
|
20
|
+
|
|
21
|
+
# smtp's host
|
|
22
|
+
host = "smtp.host"
|
|
23
|
+
port = "465"
|
|
24
|
+
# smtp's username and password
|
|
25
|
+
user = "test@test.com"
|
|
26
|
+
password = "your password"
|
|
27
|
+
|
|
28
|
+
# receiver and subject and content
|
|
29
|
+
to = "test2@test.com"
|
|
30
|
+
data = {
|
|
31
|
+
"to": to,
|
|
32
|
+
"subject": "subject of msg",
|
|
33
|
+
"content": "content of msg",
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
s = SmtpSSL(host, port, user, password)
|
|
37
|
+
r = s.send_emsg(data)
|
|
38
|
+
|
|
39
|
+
mixins
|
|
40
|
+
======
|
|
41
|
+
|
|
42
|
+
.. code-block:: python
|
|
43
|
+
|
|
44
|
+
from flask_sqlalchemy import SQLAlchemy
|
|
45
|
+
from python_plugins.models.mixins import PrimaryKeyMixin
|
|
46
|
+
from python_plugins.models.mixins import UserMixin
|
|
47
|
+
from python_plugins.models.mixins import TimestampMixin
|
|
48
|
+
|
|
49
|
+
db = SQLAlchemy()
|
|
50
|
+
|
|
51
|
+
class User(PrimaryKeyMixin,UserMixin, TimestampMixin,db.models):
|
|
52
|
+
pass
|
|
@@ -26,6 +26,12 @@ requires-python = ">=3.10"
|
|
|
26
26
|
dependencies = [
|
|
27
27
|
]
|
|
28
28
|
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
sqlalchemy = ["SQLAlchemy"]
|
|
31
|
+
cryptography = ["cryptography"]
|
|
32
|
+
pillow = ["pillow"]
|
|
33
|
+
qrcode = ["qrcode"]
|
|
34
|
+
|
|
29
35
|
[project.urls]
|
|
30
36
|
Documentation = "https://python-plugins.readthedocs.io"
|
|
31
37
|
Source = "https://github.com/ojso/python-plugins"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.2"
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import smtplib
|
|
2
|
+
from email.message import EmailMessage
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class SmtpSSL:
|
|
6
|
+
def __init__(self, host, port, user, password):
|
|
7
|
+
self.host = host
|
|
8
|
+
self.port = port
|
|
9
|
+
self.user = user
|
|
10
|
+
self.password = password
|
|
11
|
+
|
|
12
|
+
def send_emsg(self, data):
|
|
13
|
+
emsg = EmailMessage()
|
|
14
|
+
emsg["Subject"] = data["subject"]
|
|
15
|
+
emsg.set_content(data["content"])
|
|
16
|
+
|
|
17
|
+
if data.get("From") is None:
|
|
18
|
+
emsg["From"] = self.user
|
|
19
|
+
|
|
20
|
+
emsg["To"] = data["to"]
|
|
21
|
+
|
|
22
|
+
if "cc" in data:
|
|
23
|
+
emsg["Cc"] = data["cc"]
|
|
24
|
+
|
|
25
|
+
if "bcc" in data:
|
|
26
|
+
emsg["Bcc"] = data["bcc"]
|
|
27
|
+
|
|
28
|
+
# print(emsg)
|
|
29
|
+
|
|
30
|
+
with smtplib.SMTP_SSL(self.host, self.port) as smtp:
|
|
31
|
+
# smtp.set_debuglevel(1)
|
|
32
|
+
smtp.login(self.user, self.password)
|
|
33
|
+
senderrs = smtp.send_message(emsg)
|
|
34
|
+
return senderrs
|
|
File without changes
|
|
@@ -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,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
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from python_plugins.email.smtp import SmtpSSL
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@pytest.mark.skip(reason="password is empty")
|
|
6
|
+
def test_email(fake):
|
|
7
|
+
host = "smtp.qiye.aliyun.com"
|
|
8
|
+
port = "465"
|
|
9
|
+
user = "test@ojso.com"
|
|
10
|
+
# set password
|
|
11
|
+
password = ""
|
|
12
|
+
|
|
13
|
+
# set to's email
|
|
14
|
+
to = "test@ojso.com"
|
|
15
|
+
content = fake.paragraph()
|
|
16
|
+
data = {
|
|
17
|
+
"to": to,
|
|
18
|
+
"subject": "test." + fake.sentence(),
|
|
19
|
+
"content": content,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
s = SmtpSSL(host, port, user, password)
|
|
23
|
+
r = s.send_emsg(data)
|
|
24
|
+
|
|
25
|
+
assert not r
|
python_plugins-0.1.0/CHANGES.rst
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.0"
|
|
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
|