MainShortcuts2 2.4.8__tar.gz → 2.4.9__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.
Files changed (30) hide show
  1. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/PKG-INFO +1 -1
  2. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/pyproject.toml +1 -1
  3. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/_module_info.py +1 -1
  4. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/api/base.py +9 -6
  5. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/utils.py +70 -0
  6. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/README.md +0 -0
  7. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/__init__.py +0 -0
  8. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/__main__.py +0 -0
  9. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/_any2json_regs.py +0 -0
  10. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/advanced.py +0 -0
  11. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/any2json.py +0 -0
  12. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/api/gigachat.py +0 -0
  13. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/api/russian_trusted_root_ca_pem.crt +0 -0
  14. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/api/russian_trusted_sub_ca_pem.crt +0 -0
  15. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/api/webdav.py +0 -0
  16. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/cfg.py +0 -0
  17. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/core.py +0 -0
  18. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/dict.py +0 -0
  19. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/dir.py +0 -0
  20. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/file.py +0 -0
  21. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/json.py +0 -0
  22. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/list.py +0 -0
  23. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/path.py +0 -0
  24. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/proc.py +0 -0
  25. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/regex.py +0 -0
  26. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/special_chars.py +0 -0
  27. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/str.py +0 -0
  28. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/term.py +0 -0
  29. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/types.py +0 -0
  30. {mainshortcuts2-2.4.8 → mainshortcuts2-2.4.9}/src/MainShortcuts2/win.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MainShortcuts2
3
- Version: 2.4.8
3
+ Version: 2.4.9
4
4
  Summary: Сокращение и улучшение функций + консольные утилиты
5
5
  Home-page: https://github.com/MainPlay-TG/MainShortcuts2.py
6
6
  Author: MainPlay TG
@@ -1,5 +1,5 @@
1
1
  [tool.poetry]
2
- version = "2.4.8"
2
+ version = "2.4.9"
3
3
  name = "MainShortcuts2"
4
4
  description = "Сокращение и улучшение функций + консольные утилиты"
5
5
  authors = [ "MainPlay TG <xbox.roman6666666666@gmail.com>",]
@@ -1,2 +1,2 @@
1
1
  name = "MainShortcuts2"
2
- version = "2.4.8"
2
+ version = "2.4.9"
@@ -1,17 +1,20 @@
1
1
  import requests
2
- from base64 import b64encode
2
+ import requests.auth
3
+ USER_AGENTS: dict[str, str] = {}
4
+ USER_AGENTS["Android"] = "Mozilla/5.0 (Linux; Android 13; K) Chrome/128.0.6613.146"
5
+ USER_AGENTS["Android13"] = "Mozilla/5.0 (Linux; Android 13; K) Chrome/128.0.6613.146"
3
6
 
4
7
 
5
- def auth_basic(username: str, password: str, *, client: "BaseClient" = None):
8
+ def auth_basic(username: str, password: str, *, client: "BaseClient" = None) -> str:
6
9
  """Настроить базовую авторизацию для клиента"""
7
10
  if username is None:
8
11
  username = client.username
9
12
  if password is None:
10
13
  password = client.password
11
- header = "Basic " + b64encode((username + ":" + password).encode("utf-8")).decode("utf-8")
12
- if client is None:
13
- return header
14
- client._headers["Authorization"] = header
14
+ header = requests.auth._basic_auth_str(username, password)
15
+ if not client is None:
16
+ client._headers["Authorization"] = header
17
+ return header
15
18
 
16
19
 
17
20
  class BaseClient:
@@ -580,5 +580,75 @@ def is_instance_of_all(obj, *classes: type) -> bool:
580
580
  return True
581
581
 
582
582
 
583
+ def restore_deprecated(force: bool = False):
584
+ """Восстановить устаревшие функции"""
585
+ restored = []
586
+
587
+ def setmethod(cls, name):
588
+ def deco(func):
589
+ if force or not hasattr(cls, name):
590
+ try:
591
+ setattr(cls, name, func)
592
+ restored.append((cls, name, func))
593
+ except Exception:
594
+ pass
595
+ return func
596
+ return deco
597
+ if "datetime" in sys.modules:
598
+ from datetime import datetime
599
+
600
+ @setmethod(datetime, "utcnow")
601
+ def utcnow():
602
+ return datetime.now(datetime.UTC)
603
+ if "locale" in sys.modules:
604
+ import locale
605
+
606
+ @setmethod(locale, "resetlocale")
607
+ def resetlocale(category=locale.LC_ALL):
608
+ locale.setlocale(category, "")
609
+ return restored
610
+
611
+
612
+ def main_func(_name_: str, exit: bool = True):
613
+ def deco(func):
614
+ if _name_ == "__main__":
615
+ result = func()
616
+ if exit:
617
+ if isinstance(result, int):
618
+ sys.exit(result)
619
+ sys.exit()
620
+ return func
621
+ return deco
622
+
623
+
624
+ class decorators:
625
+ def __init__(self):
626
+ raise NotImplementedError()
627
+
628
+ @staticmethod
629
+ def append(obj: list):
630
+ """`obj.append(func)`"""
631
+ def deco(func):
632
+ obj.append(func)
633
+ return func
634
+ return deco
635
+
636
+ @staticmethod
637
+ def setattr(obj: type, name):
638
+ """`setattr(obj,name,func)`"""
639
+ def deco(func):
640
+ setattr(obj, name, func)
641
+ return func
642
+ return deco
643
+
644
+ @staticmethod
645
+ def setitem(obj: dict | list, index):
646
+ """`obj[index]=func`"""
647
+ def deco(func):
648
+ obj[index] = func
649
+ return func
650
+ return deco
651
+
652
+
583
653
  download_file = sync_download_file
584
654
  request = sync_request
File without changes