UserSPy-cli 1.0.0__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.
UserSPy/UserSPy.py ADDED
@@ -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
UserSPy/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from UserSPy.UserSPy import upy
UserSPy/__main__.py ADDED
@@ -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,8 @@
1
+ UserSPy/UserSPy.py,sha256=yIX_cZXaSmSUnl4a2Y-Td33mHgNx4_0v2-7yJT2CWW0,2016
2
+ UserSPy/__init__.py,sha256=gOSfzF3NGOstyas1OdPn5csJoutToPd7SW53aVfk_Zg,33
3
+ UserSPy/__main__.py,sha256=htkCEa443FNpMJop3H3SU3m0IJ1rKUxiT9nIRPVAuO0,2222
4
+ userspy_cli-1.0.0.dist-info/licenses/LICENSE,sha256=XRR_Dkl10Pc1nb6vEJZAHqCX87YzkjTVP2j41OvLxA8,42
5
+ userspy_cli-1.0.0.dist-info/METADATA,sha256=Rsaawcg_ogzgNbcQsneTVKeg6oT4u_wAP9upEOCyhzI,948
6
+ userspy_cli-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ userspy_cli-1.0.0.dist-info/top_level.txt,sha256=pDdBgUCYTxREZFHp1XR8oNVbhZCu_pEfvMvNQnL2DP0,8
8
+ userspy_cli-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ MIT License
2
+ Copyright (c) 2026 YourName
@@ -0,0 +1 @@
1
+ UserSPy