UserSPy-cli 1.0.0__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.
- userspy_cli-1.0.0/LICENSE +2 -0
- userspy_cli-1.0.0/PKG-INFO +34 -0
- userspy_cli-1.0.0/README.md +20 -0
- userspy_cli-1.0.0/UserSPy/UserSPy.py +62 -0
- userspy_cli-1.0.0/UserSPy/__init__.py +1 -0
- userspy_cli-1.0.0/UserSPy/__main__.py +61 -0
- userspy_cli-1.0.0/UserSPy_cli.egg-info/PKG-INFO +34 -0
- userspy_cli-1.0.0/UserSPy_cli.egg-info/SOURCES.txt +10 -0
- userspy_cli-1.0.0/UserSPy_cli.egg-info/dependency_links.txt +1 -0
- userspy_cli-1.0.0/UserSPy_cli.egg-info/top_level.txt +1 -0
- userspy_cli-1.0.0/pyproject.toml +21 -0
- userspy_cli-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: UserSPy-cli
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Полноценная CLI система управления пользователями на Python
|
|
5
|
+
Author-email: YourName <your_email@example.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# UserSPy
|
|
16
|
+
|
|
17
|
+
Полноценная CLI-система управления пользователями на Python.
|
|
18
|
+
|
|
19
|
+
## Установка
|
|
20
|
+
```bash
|
|
21
|
+
pip install UserSPy
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Использование в коде
|
|
25
|
+
```python
|
|
26
|
+
import UserSPy
|
|
27
|
+
db = UserSPy.upy()
|
|
28
|
+
db.make("admin", "password123")
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Использование в консоли
|
|
32
|
+
```bash
|
|
33
|
+
python -m UserSPy db.make agent007 secret_pass
|
|
34
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# UserSPy
|
|
2
|
+
|
|
3
|
+
Полноценная CLI-система управления пользователями на Python.
|
|
4
|
+
|
|
5
|
+
## Установка
|
|
6
|
+
```bash
|
|
7
|
+
pip install UserSPy
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Использование в коде
|
|
11
|
+
```python
|
|
12
|
+
import UserSPy
|
|
13
|
+
db = UserSPy.upy()
|
|
14
|
+
db.make("admin", "password123")
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Использование в консоли
|
|
18
|
+
```bash
|
|
19
|
+
python -m UserSPy db.make agent007 secret_pass
|
|
20
|
+
```
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class upy:
|
|
7
|
+
|
|
8
|
+
def __init__(self):
|
|
9
|
+
# Папка users будет создаваться в текущей рабочей директории
|
|
10
|
+
self._users_dir = os.path.join(os.getcwd(), "users")
|
|
11
|
+
if not os.path.exists(self._users_dir):
|
|
12
|
+
os.makedirs(self._users_dir, exist_ok=True)
|
|
13
|
+
|
|
14
|
+
def make(self, username, password):
|
|
15
|
+
"""Создать нового пользователя."""
|
|
16
|
+
username = str(username).strip()
|
|
17
|
+
password = str(password).strip()
|
|
18
|
+
|
|
19
|
+
if not username or not password:
|
|
20
|
+
return False
|
|
21
|
+
|
|
22
|
+
user_file = os.path.join(self._users_dir, f"{username}.json")
|
|
23
|
+
if os.path.exists(user_file):
|
|
24
|
+
return False # Уже существует
|
|
25
|
+
|
|
26
|
+
user_data = {
|
|
27
|
+
"CONFIG": {
|
|
28
|
+
"name": username,
|
|
29
|
+
"pass": password,
|
|
30
|
+
"created_at": time.strftime("%Y-%m-%d %H:%M:%S"),
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
with open(user_file, "w", encoding="utf-8") as f:
|
|
36
|
+
json.dump(user_data, f, indent=4, ensure_ascii=False)
|
|
37
|
+
return True
|
|
38
|
+
except Exception:
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
def list(self):
|
|
42
|
+
"""Вывести список пользователей."""
|
|
43
|
+
if not os.path.exists(self._users_dir):
|
|
44
|
+
return []
|
|
45
|
+
try:
|
|
46
|
+
files = [
|
|
47
|
+
f for f in os.listdir(self._users_dir) if f.endswith(".json")
|
|
48
|
+
]
|
|
49
|
+
return [os.path.splitext(f)[0] for f in files]
|
|
50
|
+
except Exception:
|
|
51
|
+
return []
|
|
52
|
+
|
|
53
|
+
def delete(self, username):
|
|
54
|
+
"""Удалить пользователя."""
|
|
55
|
+
user_file = os.path.join(self._users_dir, f"{username}.json")
|
|
56
|
+
if os.path.exists(user_file):
|
|
57
|
+
try:
|
|
58
|
+
os.remove(user_file)
|
|
59
|
+
return True
|
|
60
|
+
except Exception:
|
|
61
|
+
return False
|
|
62
|
+
return False
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from UserSPy.UserSPy import upy
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from UserSPy.UserSPy import upy
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def run_cli():
|
|
6
|
+
# Инициализируем нашу рабочую базу данных
|
|
7
|
+
db = upy()
|
|
8
|
+
|
|
9
|
+
# sys.argv — это список слов, которые вы ввели в консоль после имени скрипта
|
|
10
|
+
# sys.argv[0] — это сам запуск, sys.argv[1] — это команда (например, db.make)
|
|
11
|
+
args = sys.argv[1:]
|
|
12
|
+
|
|
13
|
+
if not args:
|
|
14
|
+
print("❌ Ошибка: Не указана команда. Пример: db.make <имя> <пароль>")
|
|
15
|
+
return
|
|
16
|
+
|
|
17
|
+
command = args[0].lower()
|
|
18
|
+
|
|
19
|
+
if command == "db.make":
|
|
20
|
+
if len(args) < 3:
|
|
21
|
+
print("❌ Ошибка: Нужно указать имя и пароль!")
|
|
22
|
+
print("Пример: python -m UserSPy db.make admin 12345")
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
username = args[1]
|
|
26
|
+
password = args[2]
|
|
27
|
+
|
|
28
|
+
if db.make(username, password):
|
|
29
|
+
print(f"✅ Пользователь '{username}' успешно создан из консоли!")
|
|
30
|
+
else:
|
|
31
|
+
print(
|
|
32
|
+
f"❌ Ошибка: Не удалось создать '{username}' (возможно, уже существует)."
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
elif command == "db.list":
|
|
36
|
+
users = db.list()
|
|
37
|
+
if not users:
|
|
38
|
+
print("📁 База данных пуста.")
|
|
39
|
+
else:
|
|
40
|
+
print("📋 Список пользователей:")
|
|
41
|
+
for u in users:
|
|
42
|
+
print(f" • {u}")
|
|
43
|
+
|
|
44
|
+
elif command == "db.delete":
|
|
45
|
+
if len(args) < 2:
|
|
46
|
+
print("❌ Ошибка: Укажите имя для удаления!")
|
|
47
|
+
return
|
|
48
|
+
|
|
49
|
+
username = args[1]
|
|
50
|
+
if db.delete(username):
|
|
51
|
+
print(f"🔥 Пользователь '{username}' успешно удален.")
|
|
52
|
+
else:
|
|
53
|
+
print(f"❌ Ошибка: Пользователь '{username}' не найден.")
|
|
54
|
+
|
|
55
|
+
else:
|
|
56
|
+
print(f"❌ Неизвестная команда '{command}'")
|
|
57
|
+
print("Доступные команды: db.make, db.list, db.delete")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
run_cli()
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: UserSPy-cli
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Полноценная CLI система управления пользователями на Python
|
|
5
|
+
Author-email: YourName <your_email@example.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# UserSPy
|
|
16
|
+
|
|
17
|
+
Полноценная CLI-система управления пользователями на Python.
|
|
18
|
+
|
|
19
|
+
## Установка
|
|
20
|
+
```bash
|
|
21
|
+
pip install UserSPy
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Использование в коде
|
|
25
|
+
```python
|
|
26
|
+
import UserSPy
|
|
27
|
+
db = UserSPy.upy()
|
|
28
|
+
db.make("admin", "password123")
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Использование в консоли
|
|
32
|
+
```bash
|
|
33
|
+
python -m UserSPy db.make agent007 secret_pass
|
|
34
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
UserSPy
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "UserSPy-cli" # Если имя UserSPy занято, PyPI попросит изменить это имя здесь
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="YourName", email="your_email@example.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "Полноценная CLI система управления пользователями на Python"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com" # Можно указать любой свой сайт или Github
|