berryworld 1.0.0.169865__py3-none-any.whl → 1.0.0.170917__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.
berryworld/email_con.py CHANGED
@@ -267,6 +267,8 @@ class EmailConnection:
267
267
  response = requests.get(url=base_url, headers=header)
268
268
  json_resp = response.json()
269
269
 
270
+ if 'value' not in json_resp.keys():
271
+ return False
270
272
  emails_df = pd.DataFrame(json_resp['value'])
271
273
  if emails_df.shape[0] > 0:
272
274
  emails_df = emails_df.loc[emails_df['isRead'] == False]
@@ -278,6 +280,9 @@ class EmailConnection:
278
280
 
279
281
  @staticmethod
280
282
  def get_mimetype(file_path):
283
+ """ Get the mimetype of the file to be attached to the email
284
+ :param file_path: Path of the file to be attached
285
+ """
281
286
  # Get mimetype
282
287
  mimetype = None
283
288
  extension = None
berryworld/sql_conn.py CHANGED
@@ -258,6 +258,7 @@ class SQLConn:
258
258
  :return: A DataFrame with the output columns requested if output is not None, else None
259
259
  :param nullable: Used within bools2bits function to indicate which boolean column values to convert
260
260
  :param commit_as_transaction: Indicate whether the connection will be done using the autocommit option or not
261
+ :param infer_int: Indicate whether the columns should be inferred to round to an integer
261
262
  """
262
263
  if output is None:
263
264
  output = []
@@ -271,6 +272,9 @@ class SQLConn:
271
272
  # Mapping the date datatype columns for SQL
272
273
  data = self.date_mapping_data_types(data)
273
274
 
275
+ # Infer integer datatype columns for SQL
276
+ data = self.int_mapping_data_types(data)
277
+
274
278
  # Mapping the boolean columns to bit
275
279
  if bools2bits:
276
280
  data = self.boolean_mapping_data_types(data, nullable)
@@ -366,6 +370,9 @@ class SQLConn:
366
370
  # Mapping the date datatype columns for SQL
367
371
  data = self.date_mapping_data_types(data)
368
372
 
373
+ # Infer integer datatype columns for SQL
374
+ data = self.int_mapping_data_types(data)
375
+
369
376
  # Mapping the boolean columns to bit
370
377
  if bools2bits:
371
378
  data = self.boolean_mapping_data_types(data, nullable)
@@ -477,6 +484,9 @@ class SQLConn:
477
484
  # Mapping date type for SQL
478
485
  data = self.date_mapping_data_types(data)
479
486
 
487
+ # Infer integer datatype columns for SQL
488
+ data = self.int_mapping_data_types(data)
489
+
480
490
  # create connection
481
491
  self.open_write_connection(commit_as_transaction)
482
492
 
@@ -616,6 +626,9 @@ class SQLConn:
616
626
  data = data[on_list + update_list]
617
627
  data = self.date_mapping_data_types(data)
618
628
 
629
+ # Infer integer datatype columns for SQL
630
+ data = self.int_mapping_data_types(data)
631
+
619
632
  # create connection
620
633
  self.open_write_connection(commit_as_transaction)
621
634
 
@@ -915,6 +928,24 @@ class SQLConn:
915
928
 
916
929
  return data
917
930
 
931
+ @staticmethod
932
+ def int_mapping_data_types(data):
933
+ """
934
+ Map integer variables so they can be inserted as integer to SQL
935
+ :param data: DataFrame containing the variables to map
936
+ :return: The mapped DataFrame
937
+ """
938
+ thres_ = 0.9
939
+ for col in data.columns:
940
+ try:
941
+ if ((~(data[col].isnull())) & (data[col].str.contains('.0', regex=False))).sum() / (
942
+ ~data[col].isnull()).sum() > thres_:
943
+ data[col] = data[col].str.replace('.0', '')
944
+ except:
945
+ continue
946
+
947
+ return data
948
+
918
949
  @staticmethod
919
950
  def boolean_mapping_data_types(data, nullable=False):
920
951
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: berryworld
3
- Version: 1.0.0.169865
3
+ Version: 1.0.0.170917
4
4
  Summary: Handy classes to improve ETL processes
5
5
  Home-page: https://www.berryworld.com
6
6
  Author: BerryWorld ltd
@@ -6,7 +6,7 @@ berryworld/app_logs_query.py,sha256=U94b-z3X9cuY_KFozupUcfaYciXWBn7p_RHkoRsfROU,
6
6
  berryworld/cache_data.py,sha256=2cStWbFQHimon_lHMbcM_0vU7lt-FCge96D-T9YXaxQ,2242
7
7
  berryworld/credentials.py,sha256=Knxo4gssLT7sbaBjOTFe3mX5k70G2e0M_6CdtlddjtA,10200
8
8
  berryworld/devops.py,sha256=BAsVonVwCXoApUOovkt-BCzwc6KnXjxRDGff_ejSGw8,9719
9
- berryworld/email_con.py,sha256=N-3R69MrqnzUSW4h9k0JJTjmzJuCKC_HkkQzClWRdX8,14142
9
+ berryworld/email_con.py,sha256=_QGA575BPVIqz7Z2AAghZCgN9YOkgDDYDpvcwnNo6ns,14358
10
10
  berryworld/email_logging.py,sha256=br2wlwoxVspEuUJJ7VXa4hUxPbBKBRfSKfTQ0GRrreI,3468
11
11
  berryworld/generate_env.py,sha256=Tk9Z_u7cA4Ve8YYTyLH2qwmLVAuYoTIWoFc0h8Va8lY,7842
12
12
  berryworld/handy_mix.py,sha256=SLCAdl2xaWEewWkECzcVFUDODDEkvUgpmJjTiccyVwU,9771
@@ -17,7 +17,7 @@ berryworld/pickle_management.py,sha256=O49ojVtTqYCT510rVRTbZWWaur_-5q3HSVG03Azn8
17
17
  berryworld/postgres_connection.py,sha256=whKDnchd5Feqpmxpoh2vlyn36EKHR-dVEULYq0N_4wA,8287
18
18
  berryworld/power_automate.py,sha256=9rDuRy0v-Ttq-SThid4lOB_tD4ibkyEmobiROpa--g4,25414
19
19
  berryworld/sharepoint_con.py,sha256=TuH-Vxk1VxjTi7x80KFssf_J8YPLRXpV27RBaFZi37U,22254
20
- berryworld/sql_conn.py,sha256=GxkCTUpGouJ9ppiP_71_nfHrxOQSjlmh6UPlIRf7L98,46191
20
+ berryworld/sql_conn.py,sha256=GAupUv4vKBiRCxdqEN-v-KOiBXY-ut8hRAx4orKrAa8,47301
21
21
  berryworld/sql_connection.py,sha256=u-2oNFC8cTP0nXkBGp62XjD06kukMFkwFMQ57CwsySQ,44364
22
22
  berryworld/teams_logging.py,sha256=8NwXyWr4fLj7W6GzAm2nRQCGFDxibQpAHDHHD24FrP8,6997
23
23
  berryworld/transportation_solver.py,sha256=AdJPekVNufweaKDZLWYIB9qSxeVti80LaoaD-4NCSjc,5038
@@ -29,8 +29,8 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  tests/test_allocation_config.py,sha256=e12l6fE9U57eSPS35g6ekJ_hol7-RHg89JV60_m1BlE,4633
30
30
  tests/test_handy_mix_config.py,sha256=Un56mz9KJmdn4K4OwzHAHLSRzDU1Xv2nFrONNuzOG04,2594
31
31
  tests/test_xml_parser.py,sha256=3QTlhFEd6KbK6nRFKZnc35tad6wqukTbe4QrFi8mr_8,859
32
- berryworld-1.0.0.169865.dist-info/LICENSE,sha256=vtkVCJM6E2af2gnsi2XxKPr4WY-uIbvzVLXieFND0UU,1074
33
- berryworld-1.0.0.169865.dist-info/METADATA,sha256=v6KAd8Z-0CHT-ZLDcWKqOeY6qSQDoH7lr5R6z6uUCD8,1107
34
- berryworld-1.0.0.169865.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
35
- berryworld-1.0.0.169865.dist-info/top_level.txt,sha256=GIZ5qy-P5oxfEH755vA1IMFeTVdX3-40JxMe6nOe5I8,17
36
- berryworld-1.0.0.169865.dist-info/RECORD,,
32
+ berryworld-1.0.0.170917.dist-info/LICENSE,sha256=vtkVCJM6E2af2gnsi2XxKPr4WY-uIbvzVLXieFND0UU,1074
33
+ berryworld-1.0.0.170917.dist-info/METADATA,sha256=w669X08mfmKkv38sih1iX7JcNT6lWBy2a9KpYcziWgk,1107
34
+ berryworld-1.0.0.170917.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
35
+ berryworld-1.0.0.170917.dist-info/top_level.txt,sha256=GIZ5qy-P5oxfEH755vA1IMFeTVdX3-40JxMe6nOe5I8,17
36
+ berryworld-1.0.0.170917.dist-info/RECORD,,