vunghixuan 0.1.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- vunghixuan-0.1.0/PKG-INFO +7 -0
- vunghixuan-0.1.0/setup.cfg +4 -0
- vunghixuan-0.1.0/setup.py +90 -0
- vunghixuan-0.1.0/src/vunghixuan/__init__.py +1 -0
- vunghixuan-0.1.0/src/vunghixuan/api_and_otp.py +23 -0
- vunghixuan-0.1.0/src/vunghixuan/create_project.py +65 -0
- vunghixuan-0.1.0/src/vunghixuan/main.py +30 -0
- vunghixuan-0.1.0/src/vunghixuan.egg-info/PKG-INFO +7 -0
- vunghixuan-0.1.0/src/vunghixuan.egg-info/SOURCES.txt +12 -0
- vunghixuan-0.1.0/src/vunghixuan.egg-info/dependency_links.txt +1 -0
- vunghixuan-0.1.0/src/vunghixuan.egg-info/entry_points.txt +2 -0
- vunghixuan-0.1.0/src/vunghixuan.egg-info/requires.txt +1 -0
- vunghixuan-0.1.0/src/vunghixuan.egg-info/top_level.txt +1 -0
- vunghixuan-0.1.0/test/test_api_otp.py +7 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
# setup.py
|
2
|
+
|
3
|
+
from setuptools import setup, find_packages
|
4
|
+
|
5
|
+
# setup(
|
6
|
+
# name='vunghixuan_package',
|
7
|
+
# version='0.1.0',
|
8
|
+
# description='API, OTP, Create Project',
|
9
|
+
# author='Đăng Thanh Vũ',
|
10
|
+
# author_email='vunghixuan@gmail.com',
|
11
|
+
# packages=find_packages(where='src'), #Tìm kiếm và liệt kê các gói con trong thư mục src, nơi chứa mã nguồn chính.
|
12
|
+
# package_dir={'': 'src'}, #Chỉ định thư mục chứa các gói, ở đây là {'': 'src'} nghĩa là gói nằm trong thư mục src.
|
13
|
+
# install_requires=['python-dotenv','requests', 'pyotp', 'setuptools'], # Các gói phụ thuộc
|
14
|
+
# entry_points={
|
15
|
+
# 'console_scripts': [
|
16
|
+
# 'vunghixuan_package=vunghixuan_package.main:main'
|
17
|
+
# ]
|
18
|
+
# }
|
19
|
+
# )
|
20
|
+
|
21
|
+
|
22
|
+
from setuptools import setup, find_packages
|
23
|
+
|
24
|
+
setup(
|
25
|
+
name='vunghixuan',
|
26
|
+
version='0.1.0',
|
27
|
+
packages=find_packages(where='src'),
|
28
|
+
description='API, OTP, Create Project',
|
29
|
+
author='Đăng Thanh Vũ',
|
30
|
+
author_email='vunghixuan@gmail.com',
|
31
|
+
package_dir={'': 'src'},
|
32
|
+
install_requires=[
|
33
|
+
'pyotp',
|
34
|
+
],
|
35
|
+
entry_points={
|
36
|
+
'console_scripts': [
|
37
|
+
'vunghixuan = vunghixuan.main:main',
|
38
|
+
],
|
39
|
+
},
|
40
|
+
)
|
41
|
+
|
42
|
+
"""
|
43
|
+
Quy trình phát hành gói Python bao gồm nhiều bước quan trọng, mỗi bước đều có chức năng riêng biệt:
|
44
|
+
|
45
|
+
1. pip install .: Lệnh này được sử dụng để cài đặt gói Python từ thư mục hiện tại. Nó sẽ tìm kiếm file setup.py và cài đặt gói theo cấu hình đã định nghĩa.
|
46
|
+
|
47
|
+
2. python setup.py sdist bdist_wheel: Lệnh này tạo ra các gói phân phối. sdist tạo ra gói nguồn, trong khi bdist_wheel tạo ra gói nhị phân (wheel). Điều này giúp người dùng có thể cài đặt gói một cách dễ dàng hơn.
|
48
|
+
|
49
|
+
Vào folder dist lấy thông tin file và: Sau khi tạo gói, bạn cần vào thư mục dist để tìm file gói đã tạo.
|
50
|
+
|
51
|
+
3. pip install dist/vunghixuan-0.1-py3-none-any.whl: Lệnh này cài đặt gói đã được tạo ra từ thư mục dist.
|
52
|
+
|
53
|
+
4. Cập nhật nếu hỏi: pip install dist/vunghixuan-0.1-py3-none-any.whl --force-reinstall: Nếu bạn cần cập nhật gói đã cài đặt, lệnh này sẽ cài đặt lại gói, bất kể phiên bản hiện tại.
|
54
|
+
|
55
|
+
5. twine upload dist/*: Cuối cùng, lệnh này được sử dụng để tải lên gói đã tạo lên PyPI, giúp người khác có thể cài đặt gói của bạn dễ dàng.
|
56
|
+
|
57
|
+
5. twine upload dist/* -u __token__ -p pypi-AgEIcHlwaS5vcmcCJDJkY2EzOTEyLTZjNzMtNDdhMy05YjBmLWM1MWY4NGZjNTZmOQACKlszLCI4OWIwMTU4NS0wNzFhLTQ1M2ItYTU2Yi1lMjU2YTAyYzUzMzkiXQAABiBFb0kaUKmOKW4r199X2i1zZMfbcNKi1DKnnR31hYkpMg
|
58
|
+
Tóm lại, bước 1 và 2 tạo môi trường local, trong khi bước 5 là bước tải lên gói lên PyPI.
|
59
|
+
|
60
|
+
6. Sử dụng lệnh gỡ bỏ: twine remove <tên-gói> --version <phiên-bản> -u __token__ -p pypi
|
61
|
+
|
62
|
+
"""
|
63
|
+
|
64
|
+
# pypi-AgEIcHlwaS5vcmcCJGRmOTZjMWEwLTg3YjEtNDQ4My1iMzc3LTVmZmIxMzdiYzkxMgACKlszLCI4OWIwMTU4NS0wNzFhLTQ1M2ItYTU2Yi1lMjU2YTAyYzUzMzkiXQAABiCqSM0HmXMCrq31YYQOx_5Up0gQaH0xbg21VpYen9CKlw
|
65
|
+
"""
|
66
|
+
[pypi]
|
67
|
+
username = __token__
|
68
|
+
password = pypi-AgEIcHlwaS5vcmcCJGRmOTZjMWEwLTg3YjEtNDQ4My1iMzc3LTVmZmIxMzdiYzkxMgACKlszLCI4OWIwMTU4NS0wNzFhLTQ1M2ItYTU2Yi1lMjU2YTAyYzUzMzkiXQAABiCqSM0HmXMCrq31YYQOx_5Up0gQaH0xbg21VpYen9CKlw
|
69
|
+
|
70
|
+
|
71
|
+
lần 2: pypi-AgEIcHlwaS5vcmcCJDJkY2EzOTEyLTZjNzMtNDdhMy05YjBmLWM1MWY4NGZjNTZmOQACKlszLCI4OWIwMTU4NS0wNzFhLTQ1M2ItYTU2Yi1lMjU2YTAyYzUzMzkiXQAABiBFb0kaUKmOKW4r199X2i1zZMfbcNKi1DKnnR31hYkpMg
|
72
|
+
|
73
|
+
[pypi]
|
74
|
+
username = __token__
|
75
|
+
password = pypi-AgEIcHlwaS5vcmcCJDJkY2EzOTEyLTZjNzMtNDdhMy05YjBmLWM1MWY4NGZjNTZmOQACKlszLCI4OWIwMTU4NS0wNzFhLTQ1M2ItYTU2Yi1lMjU2YTAyYzUzMzkiXQAABiBFb0kaUKmOKW4r199X2i1zZMfbcNKi1DKnnR31hYkpMg
|
76
|
+
|
77
|
+
Mã Otp:
|
78
|
+
obj = Otp('OXATAFVTTUIVMXNQCKMZAOFZYUYE6MGZ').get_otp()
|
79
|
+
|
80
|
+
src/
|
81
|
+
│
|
82
|
+
├── vunghixuan/
|
83
|
+
│ ├── __init__.py
|
84
|
+
│ ├── create_project.py
|
85
|
+
│ ├── api_and_otp.py
|
86
|
+
│ └── main.py
|
87
|
+
│
|
88
|
+
└── setup.py
|
89
|
+
|
90
|
+
"""
|
@@ -0,0 +1 @@
|
|
1
|
+
from .api_and_otp import APIKey, Otp
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# src/vunghixuan/create_project.py
|
2
|
+
import pyotp
|
3
|
+
class APIKey:
|
4
|
+
def __init__(self, key):
|
5
|
+
self.key = key
|
6
|
+
|
7
|
+
def get_api(self):
|
8
|
+
# Thực hiện các tác vụ của bạn
|
9
|
+
print(self.key)
|
10
|
+
|
11
|
+
class Otp:
|
12
|
+
def __init__(self):
|
13
|
+
pass
|
14
|
+
|
15
|
+
def get_otp(self, key):
|
16
|
+
# Thực hiện các tác vụ của bạn
|
17
|
+
topt = pyotp.TOTP(key)
|
18
|
+
print(topt.now())
|
19
|
+
|
20
|
+
# Đây là mã của pypi vunghixuan
|
21
|
+
def otp_vunghixuan(self):
|
22
|
+
key = 'OXATAFVTTUIVMXNQCKMZAOFZYUYE6MGZ'
|
23
|
+
self.get_otp(key)
|
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
# src/vunghixuan/create_project.py
|
3
|
+
import os
|
4
|
+
from pathlib import Path
|
5
|
+
|
6
|
+
class Project:
|
7
|
+
def __init__(self):
|
8
|
+
self.root_path = Path(__file__).parent
|
9
|
+
# self.create_project()
|
10
|
+
|
11
|
+
# def create_project(self):
|
12
|
+
# for folder, content in structure.items():
|
13
|
+
# if isinstance(content, dict):
|
14
|
+
# folder_path = os.path.join(self.root_path, folder)
|
15
|
+
# os.makedirs(folder_path)
|
16
|
+
# self.create_project()
|
17
|
+
# else:
|
18
|
+
# with open(os.path.join(folder_path, 'models', '__init__.py'), 'w') as f:
|
19
|
+
# f.write("# Init file for models\n")
|
20
|
+
|
21
|
+
# Tạo ra folder
|
22
|
+
def create_folder(self, folder_path, name):
|
23
|
+
folder_path = os.path.join(folder_path, name)
|
24
|
+
os.makedirs(folder_path, exist_ok=True)
|
25
|
+
|
26
|
+
# Tạo ra folder apps
|
27
|
+
def create_project(self):
|
28
|
+
list_folder = ['apps', 'config', 'data_base']
|
29
|
+
for folder in list_folder:
|
30
|
+
self.create_folder(self.root_path, folder)
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
def create_app(self, app_name):
|
35
|
+
folder_path = os.path.join(self.root_path, 'apps')
|
36
|
+
|
37
|
+
if not os.path.exists(folder_path):
|
38
|
+
self.create_project()
|
39
|
+
self.create_app(app_name)
|
40
|
+
else:
|
41
|
+
self.create_folder(folder_path, app_name)
|
42
|
+
folder_path = os.path.join(self.root_path, 'apps', app_name)
|
43
|
+
|
44
|
+
list_folder = ['models', 'views', 'controlers']
|
45
|
+
for folder in list_folder:
|
46
|
+
self.create_folder(folder_path, folder)
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
if __name__=="__main__":
|
57
|
+
|
58
|
+
project = Project()
|
59
|
+
|
60
|
+
# 1. Tạo ra project
|
61
|
+
# project.create_project()
|
62
|
+
|
63
|
+
# 2. Tạo app
|
64
|
+
project.create_app('app1')
|
65
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# src/vunghixuan/main.py
|
2
|
+
import sys
|
3
|
+
from .api_and_otp import APIKey, Otp
|
4
|
+
from .create_project import Project
|
5
|
+
|
6
|
+
def main():
|
7
|
+
args = sys.argv[1:]
|
8
|
+
if '-h' in args or '--help' in args:
|
9
|
+
print("Help message")
|
10
|
+
else:
|
11
|
+
key = args[1] if len(args) > 1 else None
|
12
|
+
if key:
|
13
|
+
if '-api' in args:
|
14
|
+
obj = APIKey(key)
|
15
|
+
obj.get_api()
|
16
|
+
if '-otp' in args or '-totp' in args:
|
17
|
+
obj = Otp(key)
|
18
|
+
obj.get_otp()
|
19
|
+
if '-create_project' in args :
|
20
|
+
obj = Project(key)
|
21
|
+
obj.create_project()
|
22
|
+
if '-create_app' in args :
|
23
|
+
obj = Project(key)
|
24
|
+
obj.create_app()
|
25
|
+
else:
|
26
|
+
print("Missing API key")
|
27
|
+
|
28
|
+
|
29
|
+
if __name__ == '__main__':
|
30
|
+
main()
|
@@ -0,0 +1,12 @@
|
|
1
|
+
setup.py
|
2
|
+
src/vunghixuan/__init__.py
|
3
|
+
src/vunghixuan/api_and_otp.py
|
4
|
+
src/vunghixuan/create_project.py
|
5
|
+
src/vunghixuan/main.py
|
6
|
+
src/vunghixuan.egg-info/PKG-INFO
|
7
|
+
src/vunghixuan.egg-info/SOURCES.txt
|
8
|
+
src/vunghixuan.egg-info/dependency_links.txt
|
9
|
+
src/vunghixuan.egg-info/entry_points.txt
|
10
|
+
src/vunghixuan.egg-info/requires.txt
|
11
|
+
src/vunghixuan.egg-info/top_level.txt
|
12
|
+
test/test_api_otp.py
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
pyotp
|
@@ -0,0 +1 @@
|
|
1
|
+
vunghixuan
|