optimuslib 0.0.40__py3-none-any.whl → 0.0.45__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.
optimuslib/optimuslib.py CHANGED
@@ -1354,9 +1354,12 @@ def sendDiscordBotNotificationMain(botToken,channelId,message, parse_mode=''):
1354
1354
  else:
1355
1355
  responseJson = response.result().json()
1356
1356
  try:
1357
- log.info(f'Discord Bot Message Send Failure Error Description: {responseJson['errors']['content']['_errors'][0]['code']} - {responseJson['errors']['content']['_errors'][0]['message']}')
1357
+ errorCode = responseJson['errors']['content']['_errors'][0]['code']
1358
+ errorMessage = responseJson['errors']['content']['_errors'][0]['message']
1359
+ log.info(f'Discord Bot Message Send Failure Error Description: {errorCode} - {errorMessage}')
1358
1360
  except:
1359
- log.info(f'Discord Bot Message Send Failure Error Description: {responseJson['message']}')
1361
+ errorMessage = responseJson['message']
1362
+ log.info(f'Discord Bot Message Send Failure Error Description: {errorMessage}')
1360
1363
  getVarInfo('responseJson',responseJson)
1361
1364
  return False
1362
1365
 
@@ -1376,7 +1379,29 @@ def sendDiscordBotFile(botToken,channelId,filePath):
1376
1379
  log.info('Discord Bot Message Send Failure Error Description: %s', responseJson['description'])
1377
1380
  getVarInfo('responseJson',responseJson)
1378
1381
  return False
1379
-
1382
+
1383
+
1384
+ # format table for discord message
1385
+ def buildUnicodeTable(headers, rows):
1386
+ col_widths = [len(h) for h in headers]
1387
+
1388
+ for row in rows:
1389
+ for idx, cell in enumerate(row):
1390
+ col_widths[idx] = max(col_widths[idx], len(str(cell)))
1391
+
1392
+ top_border = '┌' + '┬'.join('─' * (w + 2) for w in col_widths) + '┐'
1393
+ header_row = '│ ' + ' │ '.join(headers[i].ljust(col_widths[i]) for i in range(len(headers))) + ' │'
1394
+ mid_border = '├' + '┼'.join('─' * (w + 2) for w in col_widths) + '┤'
1395
+
1396
+ data_rows = []
1397
+ for row in rows:
1398
+ data_row = '│ ' + ' │ '.join(str(row[i]).ljust(col_widths[i]) for i in range(len(row))) + ' │'
1399
+ data_rows.append(data_row)
1400
+
1401
+ bottom_border = '└' + '┴'.join('─' * (w + 2) for w in col_widths) + '┘'
1402
+
1403
+ table = [top_border, header_row, mid_border] + data_rows + [bottom_border]
1404
+ return '\n'.join(table)
1380
1405
  # if(optimuslib.sendTelegramNotification(botToken, chatId,output)):
1381
1406
  # print('Telegram Notification Sent.')
1382
1407
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: optimuslib
3
- Version: 0.0.40
3
+ Version: 0.0.45
4
4
  Summary: Function Library for mostly used codes
5
5
  Author: Shomi Nanwani
6
6
  Requires-Python: >=3.9,<4.0
@@ -0,0 +1,5 @@
1
+ optimuslib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ optimuslib/optimuslib.py,sha256=w5cw5tk3ZTTE7fBA_qc5zV-KCsFS4k3Aba8CFqOfNj4,56245
3
+ optimuslib-0.0.45.dist-info/METADATA,sha256=ydRkxEl8_AyW4xIhZqV-WHp3nezeDTY3q6-e3BcZRms,611
4
+ optimuslib-0.0.45.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
5
+ optimuslib-0.0.45.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- optimuslib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- optimuslib/optimuslib.py,sha256=LfDWhxtOT8pyP1PlB62Drkp3Of0maBCOVlEVUr_r_yw,55211
3
- optimuslib-0.0.40.dist-info/METADATA,sha256=LpxoSjK2XHJWALiKeGySMYm-7FNcpN90YiVdVpRktT0,611
4
- optimuslib-0.0.40.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
5
- optimuslib-0.0.40.dist-info/RECORD,,