atomicshop 2.19.7__py3-none-any.whl → 2.19.8__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.19.7'
4
+ __version__ = '2.19.8'
@@ -32,6 +32,9 @@ def main():
32
32
  print_api("PIP Installing Robocorp-Recognition.")
33
33
  subprocess.check_call(["pip", "install", "--upgrade", "rpaframework-recognition"])
34
34
 
35
+ print_api("PIP Installing pynput.")
36
+ subprocess.check_call(["pip", "install", "--upgrade", "pynput"])
37
+
35
38
  print_api("Installing Playwright browsers.")
36
39
  subprocess.check_call(["playwright", "install"])
37
40
 
@@ -404,6 +404,33 @@ class MongoDBWrapper:
404
404
 
405
405
  return count
406
406
 
407
+ def aggregate_entries_in_collection(
408
+ self,
409
+ collection_name: str,
410
+ pipeline: list[dict]
411
+ ) -> list[dict]:
412
+ """
413
+ Aggregate entries in a MongoDB collection by query.
414
+
415
+ :param collection_name: str, the name of the collection.
416
+ :param pipeline: list of dictionaries, the pipeline to search for.
417
+ Example, search for all entries with column name 'name' equal to 'John':
418
+ pipeline = [{'$match': {'name': 'John'}}]
419
+ Example, return all entries from collection:
420
+ pipeline = []
421
+
422
+ :return: list of dictionaries, the list of entries that match the query.
423
+ """
424
+
425
+ self.connect()
426
+
427
+ aggregation: list[dict] = aggregate_entries_in_collection(
428
+ database=self.db, collection_name=collection_name,
429
+ pipeline=pipeline, mongo_client=self.client, close_client=False)
430
+
431
+ return aggregation
432
+
433
+
407
434
  def get_client(self):
408
435
  return self.client
409
436
 
@@ -1148,6 +1175,60 @@ def count_entries_in_collection(
1148
1175
  return count
1149
1176
 
1150
1177
 
1178
+ def aggregate_entries_in_collection(
1179
+ database: Union[str, pymongo.database.Database],
1180
+ collection_name: str,
1181
+ pipeline: list,
1182
+ mongo_client: pymongo.MongoClient = None,
1183
+ close_client: bool = False
1184
+ ) -> list:
1185
+ """
1186
+ Perform an aggregation pipeline operation on a MongoDB collection.
1187
+ For example, we count the number of entries with the same 'sha256' value that is provided in a list:
1188
+ pipeline = [
1189
+ {"$match": {"sha256": {"$in": ["hash1", "hash2"]}}},
1190
+ {"$group": {"_id": "$sha256", "count": {"$sum": 1}}}
1191
+ ]
1192
+ And we will get the result:
1193
+ [
1194
+ {"_id": "hash1", "count": 1},
1195
+ {"_id": "hash2", "count": 1}
1196
+ ]
1197
+ Meaning we will get separate counts for each 'sha256' value in the list.
1198
+
1199
+ :param database: String or the database object.
1200
+ str - the name of the database. In this case the database object will be created.
1201
+ pymongo.database.Database - the database object that will be used instead of creating a new one.
1202
+ :param collection_name: str, the name of the collection.
1203
+ :param pipeline: list, the aggregation pipeline to execute.
1204
+ Example:
1205
+ pipeline = [
1206
+ {"$match": {"sha256": {"$in": ["hash1", "hash2"]}}},
1207
+ {"$group": {"_id": "$sha256", "count": {"$sum": 1}}}
1208
+ ]
1209
+ :param mongo_client: pymongo.MongoClient, the connection object.
1210
+ If None, a new connection will be created to default URI.
1211
+ :param close_client: bool, if True, the connection will be closed after the operation.
1212
+
1213
+ :return: list, the results of the aggregation pipeline.
1214
+ """
1215
+ if not mongo_client:
1216
+ mongo_client = connect()
1217
+ close_client = True
1218
+
1219
+ db = _get_pymongo_db_from_string_or_pymongo_db(database, mongo_client)
1220
+ collection = db[collection_name]
1221
+
1222
+ # Perform aggregation
1223
+ results = collection.aggregate(pipeline)
1224
+
1225
+ if close_client:
1226
+ mongo_client.close()
1227
+
1228
+ # Return the results as a list
1229
+ return list(results)
1230
+
1231
+
1151
1232
  def delete_all_entries_from_collection(
1152
1233
  database: Union[str, pymongo.database.Database],
1153
1234
  collection_name: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.19.7
3
+ Version: 2.19.8
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=mP4RKVYs6CFRxy4SuFUKdwycVZS11TlGgfMVUl8GYy4,123
1
+ atomicshop/__init__.py,sha256=Th-y97EjSR9zstMSKi94LqlaUJmHBUAuGgdCu-K5hrQ,123
2
2
  atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
3
3
  atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
4
4
  atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
@@ -57,7 +57,7 @@ atomicshop/a_installs/win/fibratus.py,sha256=TU4e9gdZ_zI73C40uueJ59pD3qmN-UFGdX5
57
57
  atomicshop/a_installs/win/mongodb.py,sha256=AqyItXu19aaoe49pppDxtEkXey6PMy0PoT2Y_RmPpPE,179
58
58
  atomicshop/a_installs/win/nodejs.py,sha256=U519Dyt4bsQPbEg_PwnZL5tsbfqDr1BbhxwoQFZsSKo,200
59
59
  atomicshop/a_installs/win/pycharm.py,sha256=j_RSd7aDOyC3yDd-_GUTMLlQTmDrqtVFG--oUfGLiZk,140
60
- atomicshop/a_installs/win/robocorp.py,sha256=tCUrBHFynAZK81To8vRBvchOwY6BWc4LhBgTxXb0az4,2132
60
+ atomicshop/a_installs/win/robocorp.py,sha256=2E28iaRlAZROoxmXwiXv8rqTjVcdBT2UJ3B8nxrtmkc,2245
61
61
  atomicshop/a_installs/win/wsl_ubuntu_lts.py,sha256=dZbPRLNKFeMd6MotjkE6UDY9cOiIaaclIdR1kGYWI50,139
62
62
  atomicshop/a_mains/dns_gateway_setting.py,sha256=ncc2rFQCChxlNP59UshwmTonLqC6MWblrVAzbbz-13M,149
63
63
  atomicshop/a_mains/msi_unpacker.py,sha256=5hrkqETYt9HIqR_3PMf32_q06kCrIcsdm_RJV9oY438,188
@@ -266,7 +266,7 @@ atomicshop/wrappers/mongodbw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
266
266
  atomicshop/wrappers/mongodbw/install_mongodb_ubuntu.py,sha256=2eEOb35T259lhn5koynfTIm1hanxD02zN97ExGSBM2o,4021
267
267
  atomicshop/wrappers/mongodbw/install_mongodb_win.py,sha256=64EUQYx7VuMC3ndO2x3nSErh5NZ_BsqMwGvPcybfC-Q,8499
268
268
  atomicshop/wrappers/mongodbw/mongo_infra.py,sha256=IjEF0jPzQz866MpTm7rnksnyyWQeUT_B2h2DA9ryAio,2034
269
- atomicshop/wrappers/mongodbw/mongodbw.py,sha256=ih3Gd45rg_70y4sGeu0eEJ3sJd9tEN4I5IqHZelRZJw,52854
269
+ atomicshop/wrappers/mongodbw/mongodbw.py,sha256=it1TDnOF64YgDbkkBvUmUb9XGuUg6SwGnHhuqar3aHE,55929
270
270
  atomicshop/wrappers/nodejsw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
271
271
  atomicshop/wrappers/nodejsw/install_nodejs_ubuntu.py,sha256=wjpJdfAaY92RYl_L9esDIWuBMGeYH35RHJ5BVgMof8Y,6260
272
272
  atomicshop/wrappers/nodejsw/install_nodejs_windows.py,sha256=WvXIcEVnKcQYD-KNwhVP094s__1tt0Ir2Y87MABl8Nc,6283
@@ -325,8 +325,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=fgMzDXI0cybwUEqAxprRmY3lqbh
325
325
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
326
326
  atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
327
327
  atomicshop/wrappers/winregw/winreg_network.py,sha256=AENV88H1qDidrcpyM9OwEZxX5svfi-Jb4N6FkS1xtqA,8851
328
- atomicshop-2.19.7.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
329
- atomicshop-2.19.7.dist-info/METADATA,sha256=eWuLCGUrAwVSQ15odcFHEUvTyhT1m9roQxiCYJk1_t8,10630
330
- atomicshop-2.19.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
331
- atomicshop-2.19.7.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
332
- atomicshop-2.19.7.dist-info/RECORD,,
328
+ atomicshop-2.19.8.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
329
+ atomicshop-2.19.8.dist-info/METADATA,sha256=8KxTUFok-Tb489g5Kw5R07DDTmO87b3cmQC1JfAaRlY,10630
330
+ atomicshop-2.19.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
331
+ atomicshop-2.19.8.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
332
+ atomicshop-2.19.8.dist-info/RECORD,,