atomicshop 2.7.5__py3-none-any.whl → 2.7.6__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.

Potentially problematic release.


This version of atomicshop might be problematic. Click here for more details.

atomicshop/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '2.7.5'
4
+ __version__ = '2.7.6'
atomicshop/uuids.py ADDED
@@ -0,0 +1,45 @@
1
+ import uuid
2
+
3
+
4
+ """
5
+ Choosing Between UUID Versions
6
+ UUID1: Use it if you need to trace back the machine that generated the UUID.
7
+ UUID4: Use it for almost everything else, where you need a unique ID without any other implications.
8
+ UUID3 and UUID5: Use them if you need consistent UUIDs generated from the same namespace and name.
9
+
10
+ Most of the time, uuid4() is preferred due to its simplicity and randomness,
11
+ ensuring a very low probability of ID collision without depending on the machine's identity or the exact timestamp.
12
+
13
+ Collisions:
14
+ The number of random version-4 UUIDs which need to be generated in order to have a 50% probability of at least
15
+ one collision is 2.71 quintillion. This number is equivalent to generating 1 billion UUIDs per second for about
16
+ 85 years. The probability of one collision would be approximately 50% if every person on earth owns 600 million UUIDs.
17
+ https://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates
18
+ """
19
+
20
+
21
+ def generate_uuid4_random(convert_to_hex: bool = True) -> str:
22
+ """
23
+ Generate a random UUID4.
24
+
25
+ The hex attribute of a UUID object in Python returns the hexadecimal representation of the UUID as a
26
+ string of 32 hexadecimal digits. This is a more compact form compared to the standard string representation
27
+ returned by str(uuid.uuid4()), which includes hyphens.
28
+
29
+ Here's a comparison:
30
+ With Hyphens (Default String Representation): The default string representation of a UUID includes hyphens,
31
+ separating it into five groups, such as 12345678-1234-5678-1234-567812345678.
32
+ This format is easy to read and is often used in textual representations where readability is a concern.
33
+
34
+ Hexadecimal (Compact Representation): The hex attribute removes the hyphens and returns the UUID as a continuous
35
+ string of 32 hexadecimal characters, like 12345678123456781234567812345678.
36
+ This compact form might be preferred when you need a shorter version of the UUID for systems that
37
+ don't accept hyphens or when saving space is a priority.
38
+
39
+ :return:
40
+ """
41
+
42
+ if convert_to_hex:
43
+ return uuid.uuid4().hex
44
+ else:
45
+ return str(uuid.uuid4())
@@ -0,0 +1,58 @@
1
+ """
2
+ Query types:
3
+
4
+ Term Query
5
+ Usage: The term query is used for exact matches. It looks for the exact term in the inverted index and doesn’t analyze the query string. This is useful for searching on fields that are exact values (like IDs, tags, etc.).
6
+ Example: If your field value is "Quick Brown Fox" and you search with a term query for "quick" or "Quick", it will not match because it looks for the exact term in the field.
7
+
8
+ Match Query
9
+ Usage: The match query is more flexible. It analyzes the query string before executing the search. This means it will consider things like tokenization and stemming. It’s suitable for full-text search.
10
+ Example: Using the match query for "quick" or "Quick" on the field with "Quick Brown Fox" will likely return a match because it analyzes and tokenizes the string.
11
+
12
+ Match Phrase Query
13
+ Usage: The match_phrase query is like the match query but it also takes the order of the words into account. It is used when you want to find exact phrases or words in a specific order.
14
+ Example: If you search for "Quick Brown" with a match_phrase query on a field with the value "The Quick Brown Fox", it will match. However, searching for "Brown Quick" won't match.
15
+
16
+ Additional Query Types
17
+ Bool Query: This allows you to combine multiple queries using boolean logic (like must, should, must_not).
18
+ Range Query: Useful for finding numbers or dates in a given range.
19
+ Wildcard Query: For searches with wildcards, useful when the exact value is partially known.
20
+ Prefix Query: Finds documents containing terms that start with the specified prefix.
21
+ Fuzzy Query: Useful for dealing with typos and spelling variations.
22
+ """
23
+
24
+
25
+ """
26
+ AND OR:
27
+ "must" is AND
28
+ "should" is OR
29
+ "must_not" is NOT
30
+
31
+ Example with AND and OR:
32
+ You want to find all files with file_path = "/home/test1/test2/final_archive.zip" and
33
+ file_path = "test4.zip" or file_path = "_test4.zip"
34
+ Meaning you want to find all files with file_path = "/home/test1/test2/final_archive.zip/test4.zip" or
35
+ file_path = "/home/test1/test2/final_archive.zip/_test4.zip"
36
+ Since your file can be both "test4.zip" and "_test4.zip" at the same time, you need to use AND and OR.
37
+
38
+ query = {
39
+ "query": {
40
+ "bool": {
41
+ "must": [
42
+ {"match_phrase": {"file_path": "/home/test1/test2/final_archive.zip"}},
43
+ {
44
+ "bool": {
45
+ "should": [
46
+ {"match_phrase": {"file_path": "test4.zip"}},
47
+ {"match_phrase": {"file_path": "_test4.zip"}}
48
+ ]
49
+ }
50
+ }
51
+ ]
52
+ }
53
+ }
54
+ }
55
+
56
+ This is similar to Kibana KQL:
57
+ file_path : "/home/test1/test2/final_archive.zip" and (file_path : "test4.zip") or (file_path : "_test4.zip")
58
+ """
@@ -1,18 +1,33 @@
1
- def match(search_terms: dict) -> dict:
1
+ def match_and_booleans(search_terms: dict) -> dict:
2
2
  """
3
3
  Generates an Elasticsearch query based on the provided search terms.
4
4
 
5
5
  :param search_terms: A dictionary of field names and their corresponding search values.
6
6
  :return: A dictionary representing the Elasticsearch query.
7
7
 
8
- Usage:
8
+ Usage for strings:
9
9
  search_terms = {
10
10
  "field_name1": "search_term1",
11
11
  "field_name2": "search_term2"
12
12
  }
13
+
14
+ Usage for strings and booleans:
15
+ search_terms = {
16
+ "field_name1": "search_term1",
17
+ "field_name2": True
18
+ }
13
19
  """
14
20
 
15
- must_clauses = [{"match": {field: value}} for field, value in search_terms.items()]
21
+ must_clauses = []
22
+ for field, value in search_terms.items():
23
+ if isinstance(value, bool):
24
+ # Use term query for boolean values
25
+ must_clauses.append({"term": {field: value}})
26
+ else:
27
+ # Use match query for text and other types
28
+ must_clauses.append({"match": {field: value}})
29
+
30
+ # must_clauses = [{"term": {field: value}} for field, value in search_terms.items()]
16
31
 
17
32
  query = {
18
33
  "query": {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.7.5
3
+ Version: 2.7.6
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=jj6l_4UewSjOyv8e3hk7g07iNvhuQeQGLztfNXZpz3g,122
1
+ atomicshop/__init__.py,sha256=DoGkKi75FQlqIpSnJTBu70jSyzfi3tC2S62u0x9o08M,122
2
2
  atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
3
3
  atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
4
4
  atomicshop/appointment_management.py,sha256=N3wVGJgrqJfsj_lqiRfaL3FxMEe57by5Stzanh189mk,7263
@@ -40,6 +40,7 @@ atomicshop/system_resources.py,sha256=CMJfhDv6dI9K3IejpyKu-6qRlfeTphaOCd2RaLxXDy
40
40
  atomicshop/tempfiles.py,sha256=uq1ve2WlWehZ3NOTXJnpBBMt6HyCdBufqedF0HyzA6k,2517
41
41
  atomicshop/timer.py,sha256=KxBBgVM8po6pUJDW8TgY1UXj0iiDmRmL5XDCq0VHAfU,1670
42
42
  atomicshop/urls.py,sha256=CQl1j1kjEVDlAuYJqYD9XxPF1SUSgrmG8PjlcXNEKsQ,597
43
+ atomicshop/uuids.py,sha256=JSQdm3ZTJiwPQ1gYe6kU0TKS_7suwVrHc8JZDGYlydM,2214
43
44
  atomicshop/virtualization.py,sha256=LPP4vjE0Vr10R6DA4lqhfX_WaNdDGRAZUW0Am6VeGco,494
44
45
  atomicshop/web.py,sha256=K3UndqJqHO9bTogZUWDz-IEZN776KNhpk28m3Ct_pbc,11069
45
46
  atomicshop/addons/PlayWrightCodegen.cmd,sha256=Z5cnllsyXD4F1W2h-WLEnyFkg5nZy0-hTGHRWXVOuW4,173
@@ -157,8 +158,9 @@ atomicshop/wrappers/elasticsearchw/config_basic.py,sha256=nMtWYBlkQwzUMTLBaL3US8
157
158
  atomicshop/wrappers/elasticsearchw/elasticsearchw.py,sha256=KCU1OgzqG4YALQkVZqF6tpsCG-gU_SkJa1HQK6zV07A,7301
158
159
  atomicshop/wrappers/elasticsearchw/queries/__init__.py,sha256=KBjT-bAt75CJsx1Apko9mpuFU4pfZV8DcGWQvpX65RU,78
159
160
  atomicshop/wrappers/elasticsearchw/queries/aggregation.py,sha256=N9a5yMMnb10sMa_x1qJBFQpgyJ49UWo8_vxuqmUtZ1A,1742
161
+ atomicshop/wrappers/elasticsearchw/queries/info.py,sha256=e2O_vW8admhs5-kyoSGkZYHGK2O-hfdAOsWuMZzY0D4,2821
160
162
  atomicshop/wrappers/elasticsearchw/queries/pagination.py,sha256=ySPJuXZOMiNAo7SDycxVOg35uP-CK59GzrLbs-0CqcM,509
161
- atomicshop/wrappers/elasticsearchw/queries/query_multi.py,sha256=cNvE4emJ5tXka522uLNwIzangVR4Cc4evVgznQmxTV8,656
163
+ atomicshop/wrappers/elasticsearchw/queries/query_multi.py,sha256=hiqLqX3_Go_QKZpcyEXr9Qvyxf6uKHP3IS6JSNzChL4,1167
162
164
  atomicshop/wrappers/elasticsearchw/queries/query_single.py,sha256=HdYBW17vIvmHTI3nviOBmMspefDCT4xWXXnK7cbE2gQ,2662
163
165
  atomicshop/wrappers/elasticsearchw/queries/size.py,sha256=ZThvspfxpXRBI6Mht9kkb5lO-9KtprXqll_jBxDggns,319
164
166
  atomicshop/wrappers/elasticsearchw/queries/sort.py,sha256=-CUhgcs_AVRvncRlLTl5IJZE8K3RgDNLYSIHnn0j7aE,1274
@@ -220,8 +222,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=AhpurHJmP2kgzHaUbq5ey
220
222
  atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
221
223
  atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
222
224
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
223
- atomicshop-2.7.5.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
224
- atomicshop-2.7.5.dist-info/METADATA,sha256=AIuzrvfrjYEu2KcejaTW1v_XlHLUOofsz3krDbTY3iY,10369
225
- atomicshop-2.7.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
226
- atomicshop-2.7.5.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
227
- atomicshop-2.7.5.dist-info/RECORD,,
225
+ atomicshop-2.7.6.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
226
+ atomicshop-2.7.6.dist-info/METADATA,sha256=ouPceXaGo8HF2r-OEYqADM0a2mpeM_V7zvxoLrqJTwE,10369
227
+ atomicshop-2.7.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
228
+ atomicshop-2.7.6.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
229
+ atomicshop-2.7.6.dist-info/RECORD,,