smartsheet-tools 0.0.7__py3-none-any.whl → 0.0.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.
- smartsheet_tools/__init__.py +25 -2
- {smartsheet_tools-0.0.7.dist-info → smartsheet_tools-0.0.8.dist-info}/METADATA +1 -1
- smartsheet_tools-0.0.8.dist-info/RECORD +6 -0
- {smartsheet_tools-0.0.7.dist-info → smartsheet_tools-0.0.8.dist-info}/WHEEL +1 -1
- smartsheet_tools-0.0.7.dist-info/RECORD +0 -6
- {smartsheet_tools-0.0.7.dist-info → smartsheet_tools-0.0.8.dist-info}/licenses/LICENSE +0 -0
- {smartsheet_tools-0.0.7.dist-info → smartsheet_tools-0.0.8.dist-info}/top_level.txt +0 -0
smartsheet_tools/__init__.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
|
+
import time
|
|
2
3
|
import re
|
|
3
|
-
|
|
4
|
+
import warnings
|
|
5
|
+
from smartsheet.models import Cell, Row, Folder, Sheet, Error
|
|
4
6
|
from smartsheet.models import Column
|
|
5
7
|
|
|
6
8
|
# Cache for column types to minimize API calls when correcting date formats
|
|
@@ -163,6 +165,27 @@ def walk_workspace_for_folders(smartsheet_client, workspace_id):
|
|
|
163
165
|
def walk_sheet_names_from_workspace(smartsheet_client, workspace_id):
|
|
164
166
|
for sheet in walk_workspace_for_sheets(smartsheet_client, workspace_id):
|
|
165
167
|
yield sheet.name
|
|
168
|
+
|
|
169
|
+
def safe_grab_sheet_by_name(name, smartsheet_client, max_tries=5, delay_seconds=15):
|
|
170
|
+
last_error = None
|
|
171
|
+
for attempt in range(1, max_tries + 1):
|
|
172
|
+
try:
|
|
173
|
+
result = smartsheet_client.Sheets.get_sheet_by_name(name)
|
|
174
|
+
except Exception as exc:
|
|
175
|
+
last_error = exc
|
|
176
|
+
result = None
|
|
177
|
+
|
|
178
|
+
if isinstance(result, Sheet):
|
|
179
|
+
return result
|
|
180
|
+
|
|
181
|
+
if isinstance(result, Error):
|
|
182
|
+
last_error = result
|
|
183
|
+
|
|
184
|
+
if attempt < max_tries:
|
|
185
|
+
warnings.warn(f"failed to grab sheet {name} trying again in {delay_seconds}s")
|
|
186
|
+
time.sleep(delay_seconds)
|
|
187
|
+
|
|
188
|
+
raise RuntimeError(f"failed to grab sheet {name} after {max_tries} tries") from (last_error if isinstance(last_error, Exception) else None)
|
|
166
189
|
|
|
167
190
|
def new_column(column_type, title, index=None, id=None, options=None, symbol=None, primary=False, hidden=False, locked=False):
|
|
168
191
|
new_column = Column()
|
|
@@ -183,4 +206,4 @@ def new_column(column_type, title, index=None, id=None, options=None, symbol=Non
|
|
|
183
206
|
new_column.hidden = True
|
|
184
207
|
if locked:
|
|
185
208
|
new_column.locked = True
|
|
186
|
-
return new_column
|
|
209
|
+
return new_column
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: smartsheet_tools
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: A collection of convenience functions to aid with transitioning from simple-smartsheet to the SDK API and common tasks
|
|
5
5
|
Author: Ashton Pooley
|
|
6
6
|
Author-email: Ashton Pooley <ashton@ashi.digital>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
smartsheet_tools/__init__.py,sha256=3cHkGYvGumRIyJ1qn4xFC4xTbfavAQtw1JXU7VmYAWw,7612
|
|
2
|
+
smartsheet_tools-0.0.8.dist-info/licenses/LICENSE,sha256=xshMXNQ83e1x1bG3-9fQ5U8hnMaJsv79ke3xuKmI2PI,31914
|
|
3
|
+
smartsheet_tools-0.0.8.dist-info/METADATA,sha256=lYU6SyI8JaIHTqnRrz_hE2enrkTXcUQnEuYGzS-t3Zw,834
|
|
4
|
+
smartsheet_tools-0.0.8.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
5
|
+
smartsheet_tools-0.0.8.dist-info/top_level.txt,sha256=UXKUTK6mn1resx7hDN-MqSLi6ZnojUbkJ44VzmNmYi8,17
|
|
6
|
+
smartsheet_tools-0.0.8.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
smartsheet_tools/__init__.py,sha256=whnuWHiAyhEcRHQLF178lptsvjULJWReznb1IomVglo,6786
|
|
2
|
-
smartsheet_tools-0.0.7.dist-info/licenses/LICENSE,sha256=xshMXNQ83e1x1bG3-9fQ5U8hnMaJsv79ke3xuKmI2PI,31914
|
|
3
|
-
smartsheet_tools-0.0.7.dist-info/METADATA,sha256=5hqqP0dXb5kdc65oc2eD97VyCwqcZfNT4GA4o38cGRk,834
|
|
4
|
-
smartsheet_tools-0.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
5
|
-
smartsheet_tools-0.0.7.dist-info/top_level.txt,sha256=UXKUTK6mn1resx7hDN-MqSLi6ZnojUbkJ44VzmNmYi8,17
|
|
6
|
-
smartsheet_tools-0.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|