anb-python-components 1.4.2__tar.gz → 1.4.3__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 (64) hide show
  1. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/PKG-INFO +1 -2
  2. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/classes/action_state.py +1 -0
  3. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/custom_types/guid.py +32 -32
  4. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/custom_types/object_array.py +320 -166
  5. anb_python_components-1.4.3/anb_python_components/models/action_state_message.py +25 -0
  6. anb_python_components-1.4.3/anb_python_components/models/shortcode_model.py +23 -0
  7. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components.egg-info/PKG-INFO +1 -2
  8. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/setup.py +1 -2
  9. anb_python_components-1.4.3/tests/custom_types/guid_test.py +271 -0
  10. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/custom_types/object_array_test.py +43 -30
  11. anb_python_components-1.4.2/anb_python_components/models/action_state_message.py +0 -27
  12. anb_python_components-1.4.2/anb_python_components/models/shortcode_model.py +0 -31
  13. anb_python_components-1.4.2/tests/custom_types/guid_test.py +0 -14
  14. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/LICENSE +0 -0
  15. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/README.md +0 -0
  16. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/__init__.py +0 -0
  17. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/classes/__init__.py +0 -0
  18. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/classes/dataclass_analyzer.py +0 -0
  19. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/classes/directory.py +0 -0
  20. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/classes/file.py +0 -0
  21. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/classes/interface.py +0 -0
  22. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/classes/shortcode_parser.py +0 -0
  23. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/custom_types/__init__.py +0 -0
  24. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/custom_types/shortcode_attributes.py +0 -0
  25. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/custom_types/two_dim_size.py +0 -0
  26. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/custom_types/version_info.py +0 -0
  27. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/decorators/__init__.py +0 -0
  28. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/decorators/interface_decorators.py +0 -0
  29. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/enums/__init__.py +0 -0
  30. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/enums/message_type.py +0 -0
  31. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/enums/not_bool_action.py +0 -0
  32. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/enums/type_copy_strategy.py +0 -0
  33. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/exceptions/__init__.py +0 -0
  34. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/exceptions/wrong_type_exception.py +0 -0
  35. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/extensions/__init__.py +0 -0
  36. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/extensions/array_extension.py +0 -0
  37. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/extensions/bool_extension.py +0 -0
  38. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/extensions/dataclass_extension.py +0 -0
  39. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/extensions/string_extension.py +0 -0
  40. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/extensions/string_extension_constant.py +0 -0
  41. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/extensions/type_extension.py +0 -0
  42. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components/models/__init__.py +0 -0
  43. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components.egg-info/SOURCES.txt +0 -0
  44. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components.egg-info/dependency_links.txt +0 -0
  45. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components.egg-info/not-zip-safe +0 -0
  46. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components.egg-info/requires.txt +0 -0
  47. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/anb_python_components.egg-info/top_level.txt +0 -0
  48. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/setup.cfg +0 -0
  49. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/__init__.py +0 -0
  50. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/classes/__init__.py +0 -0
  51. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/classes/action_state_test.py +0 -0
  52. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/classes/dataclass_analyzer_test.py +0 -0
  53. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/classes/directory_test.py +0 -0
  54. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/classes/file_test.py +0 -0
  55. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/classes/interface_test.py +0 -0
  56. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/classes/shortcode_parser_test.py +0 -0
  57. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/custom_types/__init__.py +0 -0
  58. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/custom_types/two_dim_size_test.py +0 -0
  59. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/custom_types/version_info_test.py +0 -0
  60. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/extensions/__init__.py +0 -0
  61. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/extensions/array_extension_test.py +0 -0
  62. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/extensions/bool_extension_test.py +0 -0
  63. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/extensions/string_extension_test.py +0 -0
  64. {anb_python_components-1.4.2 → anb_python_components-1.4.3}/tests/extensions/type_extension_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anb_python_components
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: Набор компонентов Python, которые упрощают разработку / A set of Python components that simplify development
5
5
  Home-page: https://gitflic.ru/project/babaev-an/anb-python-components
6
6
  Author: Александр Бабаев
@@ -12,7 +12,6 @@ Keywords: python components development utils
12
12
  Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: License :: OSI Approved :: MIT License
15
- Classifier: Programming Language :: Python :: 3
16
15
  Classifier: Programming Language :: Python :: 3.14
17
16
  Classifier: Operating System :: OS Independent
18
17
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
@@ -6,6 +6,7 @@ from anb_python_components.enums.message_type import MessageType
6
6
  from anb_python_components.exceptions.wrong_type_exception import WrongTypeException
7
7
  from anb_python_components.models.action_state_message import ActionStateMessage
8
8
 
9
+ # noinspection Annotator
9
10
  class ActionState[T]:
10
11
  """
11
12
  Класс для хранения состояния действия.
@@ -20,7 +20,7 @@ class GUID:
20
20
  :param guid: str | GUID - Передаваемый GUID
21
21
  """
22
22
  # Проверка типа аргумента guid
23
- if not isinstance(guid, str) or not isinstance(guid, GUID):
23
+ if not isinstance(guid, str) and not isinstance(guid, GUID):
24
24
  # - если аргумент не является строкой или экземпляром GUID, то генерируем исключение
25
25
  raise WrongTypeException("Неверный тип аргумента!", "GUID", str(type(guid)), "guid")
26
26
 
@@ -61,47 +61,47 @@ class GUID:
61
61
  def generate () -> GUID:
62
62
  """
63
63
  Генерирует уникальный идентификатор GUID согласно стандарту RFC 4122.
64
+ :return: Уникальный GUID в виде экземпляра GUID.
64
65
  """
65
- # Генерация отдельных компонентов GUID
66
- time_low = secrets.randbits(32) & 0xffffffff
67
- time_mid = secrets.randbits(16) & 0xffff
68
- time_hi_and_version = ((secrets.randbits(12) << 4) | 0x4000) & 0xffff
69
- clock_seq_hi_and_reserved = ((secrets.randbits(14) << 2) | 0x8000) & 0xffff
70
- node_id = secrets.randbits(48) & 0xffffffffffff
71
-
72
- # Объединение компонентов в единый GUID
73
- guid_parts = [
74
- time_low >> 16, time_low & 0xffff,
75
- time_mid,
76
- time_hi_and_version,
77
- clock_seq_hi_and_reserved,
78
- node_id >> 32, (node_id >> 16) & 0xffff, node_id & 0xffff
79
- ]
80
-
81
- # Форматируем компоненты в виде строки GUID
82
- guid_str = "-".join(
83
- [
84
- "%08x" % guid_parts[0],
85
- "%04x" % guid_parts[1],
86
- "%04x" % guid_parts[2],
87
- "%04x" % guid_parts[3],
88
- ("%04x%04x%04x" % tuple(guid_parts[4:])),
89
- ]
90
- )
91
-
92
- # Возвращаем экземпляр GUID
66
+ # Генерируем все биты сразу (128 бит)
67
+ full_guid = secrets.token_bytes(16) # 16 байт = 128 бит
68
+
69
+ # Преобразуем в массив байт для манипуляции
70
+ guid_bytes = bytearray(full_guid)
71
+
72
+ # Устанавливаем версию (4) в 7‑м байте (биты 4–7)
73
+ guid_bytes[7] = (guid_bytes[7] & 0x0F) | 0x40 # 0x40 = 01000000
74
+ # Устанавливаем вариант (1) в 8‑м байте (биты 6–7)
75
+ guid_bytes[8] = (guid_bytes[8] & 0x3F) | 0x80 # 0x80 = 10000000
76
+
77
+ # Формируем строку GUID
78
+ hex_str = guid_bytes.hex() # 32 hex-цифры
79
+ guid_str = (
80
+ f"{hex_str[0:8]}-"
81
+ f"{hex_str[8:12]}-"
82
+ f"{hex_str[12:16]}-"
83
+ f"{hex_str[16:20]}-"
84
+ f"{hex_str[20:32]}"
85
+ )
86
+
87
+ # Возвращаем GUID
93
88
  return GUID(guid_str)
94
89
 
95
90
  @staticmethod
96
91
  def is_equal (guid1: str | GUID, guid2: str | GUID) -> bool:
97
-
92
+ """
93
+ Сравнение двух GUID.
94
+ :param guid1: Первый GUID.
95
+ :param guid2: Второй GUID.
96
+ :return: True, если GUID равны, иначе False.
97
+ """
98
98
  # Если guid1 не является GUID или строкой
99
- if not isinstance(guid1, GUID) or not isinstance(guid1, str):
99
+ if not isinstance(guid1, GUID) and not isinstance(guid1, str):
100
100
  # - генерируем исключение
101
101
  raise WrongTypeException("Неверный тип аргумента!", "GUID|str", var_name = "guid1")
102
102
 
103
103
  # Если guid2 не является GUID или строкой
104
- if not isinstance(guid2, GUID) or not isinstance(guid2, str):
104
+ if not isinstance(guid2, GUID) and not isinstance(guid2, str):
105
105
  # - генерируем исключение
106
106
  raise WrongTypeException("Неверный тип аргумента!", "GUID|str", var_name = "guid2")
107
107