berryworld 1.0.0.199448__py3-none-any.whl → 1.0.0.200414__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
@@ -1,3 +1,4 @@
1
+ import os
1
2
  import ast
2
3
  import base64
3
4
  import json
@@ -136,6 +137,10 @@ class EmailConnection:
136
137
  :param extension_files: Indicate the file extensions to download and skip others
137
138
  :param emails_to_query: Number of emails to be queried when the method is called
138
139
  """
140
+ '''
141
+ folder_name = 'Ingestion/CircanaExports'
142
+ '''
143
+
139
144
  header = copy.copy(self.headers)
140
145
  folder_id = self.get_folder_id(folder_name)
141
146
 
@@ -182,6 +187,7 @@ class EmailConnection:
182
187
  attachments_df = pd.DataFrame(response.json()['value'])[['id', 'name', 'contentBytes']]
183
188
  attachments_df = attachments_df.assign(**{'MessageId': msg["id"]})
184
189
  attachments_df = attachments_df.loc[attachments_df['name'].str.contains('|'.join(extension_files))]
190
+ attachments_df['name'] = attachments_df['name'].str.replace(r'[\\/*?:"<>|]', "", regex=True)
185
191
  all_attachments = pd.concat([all_attachments, attachments_df])
186
192
  for _, attachment in attachments_df.iterrows():
187
193
  f = open(attachment['name'], 'w+b')
@@ -321,37 +327,42 @@ class EmailConnection:
321
327
  :param file_path: Path of the file to be attached
322
328
  """
323
329
  # Get mimetype
324
- if ('.jpg' in file_path) | ('.jpeg' in file_path):
330
+ ext = os.path.splitext(file_path)[1].lower()
331
+ if ext in ('.jpg', '.jpeg'):
325
332
  mimetype = "image/jpeg"
326
333
  extension = '.jpeg'
327
- elif '.png' in file_path:
334
+ elif ext == '.png':
328
335
  mimetype = "image/png"
329
336
  extension = '.png'
330
- elif '.doc' in file_path:
337
+ elif ext == '.doc':
331
338
  mimetype = "application/msword"
332
339
  extension = '.doc'
333
- elif '.docx' in file_path:
340
+ elif ext == '.docx':
334
341
  mimetype = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
335
342
  extension = '.docx'
336
- elif '.pdf' in file_path:
343
+ elif ext == '.pdf':
337
344
  mimetype = "application/pdf"
338
345
  extension = '.pdf'
339
- elif '.txt' in file_path:
346
+ elif ext == '.txt':
340
347
  mimetype = "text/plain"
341
348
  extension = '.txt'
342
- elif '.csv' in file_path:
349
+ elif ext == '.csv':
343
350
  mimetype = "text/csv"
344
351
  extension = '.csv'
345
- elif '.xls' in file_path:
352
+ elif ext == '.xls':
346
353
  mimetype = "application/vnd.ms-excel"
347
354
  extension = '.xls'
348
- elif '.xlsx' in file_path:
349
- mimetype = "application/vnd.ms-excel"
355
+ elif ext == '.xlsx':
356
+ mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
350
357
  extension = '.xlsx'
351
- elif '.html' in file_path:
352
- mimetype = "application/vnd.ms-excel"
353
- extension = 'text/html'
358
+ elif ext in ('.html', '.htm'):
359
+ mimetype = "text/html"
360
+ extension = ext
361
+ elif ext == '.zip':
362
+ mimetype = "application/zip"
363
+ extension = '.zip'
354
364
  else:
355
- raise Exception('File mime type not found')
365
+ mimetype = "application/octet-stream"
366
+ extension = ext
356
367
 
357
368
  return mimetype, extension
@@ -1007,7 +1007,7 @@ class SQLConnection:
1007
1007
  :param string: String variable to parse
1008
1008
  :return: Parsed string
1009
1009
  """
1010
- string = re.sub(r"Decimal\(\s*'\"['\"]\s*\)", r"\1", string)
1010
+ string = re.sub(r"Decimal\('\s*([^)]+?)\s*'\)", r'\1', string)
1011
1011
  return string
1012
1012
 
1013
1013
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: berryworld
3
- Version: 1.0.0.199448
3
+ Version: 1.0.0.200414
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=AWAhV4PPkilZ4Xb1pUXuuu6UdHICAx8QqDtb9rVnjDM,2254
7
7
  berryworld/credentials.py,sha256=sF77pWfMxHMyULiBgBeQzXXRJscPRA_ncRAGOeGYDAw,5754
8
8
  berryworld/devops.py,sha256=7mRbyZPGzk5ox-6J2etv3NxCcfP4cprG0_Xelh7prn8,9776
9
- berryworld/email_con.py,sha256=CVyEDVnc_iVeRTwJgIU31ToFgyix7L2yn4Ih9Wu7I5s,15806
9
+ berryworld/email_con.py,sha256=1dsj4KtThuvhbcKYgbZcGLCX9mkrV0fMD2a1zDW99F8,16126
10
10
  berryworld/email_logging.py,sha256=LeSrTExhQhar49gJR2wGC1dS0lqsNpFl9pS3eYWqnuo,4936
11
11
  berryworld/generate_env.py,sha256=LrqUH8AjCI6P0uU6BMBRYC9cnmyKkYcpXF1KKIzxkZ8,15900
12
12
  berryworld/handy_mix.py,sha256=SqJ3UjIjmIOgjbp-_1eyKQJ3OJLN7OfpDQIASvjNZ_Q,9672
@@ -20,19 +20,19 @@ berryworld/python_logs.py,sha256=FVPK1rtFvwRRxtDnBVc9SinyAkt6K2G1HIzIvtS7WWE,517
20
20
  berryworld/sharepoint_con.py,sha256=nmyZJIcaAKJ6Y-ti4gQbvzA_rRbrMGIxTDXe4eP-tiI,44950
21
21
  berryworld/snowflake_conn.py,sha256=L0ePgTKa3tvaxj88BZmsjS6cFp3ZU3rytw7S2jkuA-U,3161
22
22
  berryworld/sql_conn.py,sha256=7MjtymH4_NvLbxnmoVY6ViiNKSp4jPkGluOfgEZ8txA,47645
23
- berryworld/sql_connection.py,sha256=KOA8y8SJgRIB6DXqIYqakydLZqYbmZAreUOi-Ii4hr0,104104
23
+ berryworld/sql_connection.py,sha256=XXrau3HwrLTMqKXOsBz533ZDBXj4NLYvFdGp71dwbls,104106
24
24
  berryworld/teams_logging.py,sha256=8NwXyWr4fLj7W6GzAm2nRQCGFDxibQpAHDHHD24FrP8,6997
25
25
  berryworld/transportation_solver.py,sha256=tNc1JJk71azIBccdWVHbqcvXWhalOdKffv6HmBD6tG0,5014
26
26
  berryworld/verify_keys.py,sha256=X7VUHqYDklWPDO0bGVHIOXeLq5Qi4fZRZbHYw5x7UnA,4356
27
27
  berryworld/vivantio.py,sha256=QfZo0UKqkzVRg_LyiwivNd3aEup4TH57x4KxLZkCJwc,10627
28
28
  berryworld/vivantio_logging.py,sha256=ciy7gA4u3FrgUIpEBnMgocbNPp6jcu9TPoy-kLcrTZU,5736
29
29
  berryworld/xml_parser.py,sha256=HWD71NaTN3DaIOGT6Wzxs4CEsroFhGQwe9iPLIL80Co,957
30
- berryworld-1.0.0.199448.dist-info/licenses/LICENSE,sha256=vtkVCJM6E2af2gnsi2XxKPr4WY-uIbvzVLXieFND0UU,1074
30
+ berryworld-1.0.0.200414.dist-info/licenses/LICENSE,sha256=vtkVCJM6E2af2gnsi2XxKPr4WY-uIbvzVLXieFND0UU,1074
31
31
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  tests/test_allocation_config.py,sha256=e12l6fE9U57eSPS35g6ekJ_hol7-RHg89JV60_m1BlE,4633
33
33
  tests/test_handy_mix_config.py,sha256=Un56mz9KJmdn4K4OwzHAHLSRzDU1Xv2nFrONNuzOG04,2594
34
34
  tests/test_xml_parser.py,sha256=3QTlhFEd6KbK6nRFKZnc35tad6wqukTbe4QrFi8mr_8,859
35
- berryworld-1.0.0.199448.dist-info/METADATA,sha256=bJsVwnk0PBddGk6C6nbyH5oxlrvKHiaMU1HEUueLZc0,1445
36
- berryworld-1.0.0.199448.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- berryworld-1.0.0.199448.dist-info/top_level.txt,sha256=GIZ5qy-P5oxfEH755vA1IMFeTVdX3-40JxMe6nOe5I8,17
38
- berryworld-1.0.0.199448.dist-info/RECORD,,
35
+ berryworld-1.0.0.200414.dist-info/METADATA,sha256=_i6gXJbrq9E6lWx2AVxs8LTkaTUdj4AuoCA0wLfCyos,1445
36
+ berryworld-1.0.0.200414.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
37
+ berryworld-1.0.0.200414.dist-info/top_level.txt,sha256=GIZ5qy-P5oxfEH755vA1IMFeTVdX3-40JxMe6nOe5I8,17
38
+ berryworld-1.0.0.200414.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5