xlwings-utils 25.1.2__py3-none-any.whl → 25.1.3__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 xlwings-utils might be problematic. Click here for more details.

@@ -5,7 +5,7 @@
5
5
  # /_/\_\|_| \_/\_/ |_||_| |_| \__, ||___/ _____ \__,_| \__||_||_||___/
6
6
  # |___/ |_____|
7
7
 
8
- __version__ = "25.1.2"
8
+ __version__ = "25.1.3"
9
9
 
10
10
 
11
11
  from pathlib import Path
@@ -15,6 +15,8 @@ import math
15
15
  import base64
16
16
  import requests
17
17
  import json
18
+ import datetime
19
+ import functools
18
20
 
19
21
  Pythonista = sys.platform == "ios"
20
22
 
@@ -211,7 +213,10 @@ def write_dropbox(dropbox_path, contents):
211
213
  "Content-Type": "application/octet-stream",
212
214
  }
213
215
  response = requests.post("https://content.dropboxapi.com/2/files/upload", headers=headers, data=contents)
214
- return response
216
+ try:
217
+ response.raise_for_status()
218
+ except requests.exceptions.HTTPError as e:
219
+ raise FileNotFoundError(f"file {str(dropbox_path)} could not be written. Original message is {e}") from None
215
220
 
216
221
 
217
222
  def delete_from_dropbox(dropbox_path):
@@ -235,9 +240,10 @@ def delete_from_dropbox(dropbox_path):
235
240
  data = {"path": str(dropbox_path)} # Path in Dropbox, starting with /
236
241
 
237
242
  response = requests.post("https://api.dropboxapi.com/2/files/delete_v2", headers=headers, data=json.dumps(data))
238
- if response.status_code == 200:
239
- return response
240
- raise FileNotFoundError(f"dropbox file {dropbox_path} not found")
243
+ try:
244
+ response.raise_for_status()
245
+ except requests.exceptions.HTTPError as e:
246
+ raise FileNotFoundError(f"file {str(dropbox_path)} could not be deleted. Original message is {e}") from None
241
247
 
242
248
 
243
249
  def list_local(path, recursive=False, show_files=True, show_folders=False):
@@ -1037,6 +1043,29 @@ def trigger_macro(sheet):
1037
1043
  sheet["A1"].value = "=NOW()"
1038
1044
 
1039
1045
 
1046
+ def timer(func):
1047
+ """
1048
+ this decorator should be placed after the @xw.script decorator
1049
+
1050
+ it will show the name, entry time, exit time and the duration, like
1051
+ Done MyScript 11:51:13.24 - 11:51:20.28 (7.04s)
1052
+
1053
+ """
1054
+
1055
+ @functools.wraps(func)
1056
+ def wrapper(*args, **kwargs):
1057
+ result = func(*args, **kwargs)
1058
+ now1 = datetime.datetime.now()
1059
+ t0 = now0.second + now0.microsecond / 1_000_000
1060
+ t1 = now1.second + now1.microsecond / 1_000_000
1061
+ print(
1062
+ f"Done {func.__name__} {now0:%H:%M:%S.}{int(now0.microsecond / 10000):02d} - {now1:%H:%M:%S.}{int(now1.microsecond / 10000):02d} ({t1 - t0:.2f}s)"
1063
+ )
1064
+ return result
1065
+
1066
+ now0 = datetime.datetime.now()
1067
+ return wrapper
1068
+
1069
+
1040
1070
  if __name__ == "__main__":
1041
1071
  ...
1042
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xlwings_utils
3
- Version: 25.1.2
3
+ Version: 25.1.3
4
4
  Summary: xlwings_utils
5
5
  Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/salabim/xlwings_utils
@@ -0,0 +1,6 @@
1
+ xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
2
+ xlwings_utils/xlwings_utils.py,sha256=NLpcQZ8ySetC__8PnNiZWzFhGkdB3nLP1PsnKgVtu98,31524
3
+ xlwings_utils-25.1.3.dist-info/METADATA,sha256=2DM1oIGQKxTvfDa5bl4OrZwEsvOcdTUcC-U4XVacJ9Q,12265
4
+ xlwings_utils-25.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ xlwings_utils-25.1.3.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
6
+ xlwings_utils-25.1.3.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
2
- xlwings_utils/xlwings_utils.py,sha256=z-N00D0O_0LyhDOhpHuAI2Ddphig40-LpgWS9rOIr_c,30481
3
- xlwings_utils-25.1.2.dist-info/METADATA,sha256=Kg-GSXueKT9vbNCTaX1EBt-4zB5k7JOHUezbhWBncMY,12265
4
- xlwings_utils-25.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
- xlwings_utils-25.1.2.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
6
- xlwings_utils-25.1.2.dist-info/RECORD,,