smartsheet-tools 0.0.7__tar.gz → 0.0.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: smartsheet_tools
3
- Version: 0.0.7
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>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "smartsheet_tools" # from setup.py
7
- version = "0.0.7" # from setup.py
7
+ version = "0.0.8" # from setup.py
8
8
  description = "A collection of convenience functions to aid with transitioning from simple-smartsheet to the SDK API and common tasks"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9" # matches classifiers (3.9–3.12)
@@ -2,7 +2,7 @@ from setuptools import setup
2
2
 
3
3
  setup(
4
4
  name="smartsheet_tools",
5
- version="0.0.7",
5
+ version="0.0.8",
6
6
  description="A collection of convenience functions to aid with transitioning from simple-smartsheet to the SDK API and common tasks",
7
7
  author="Ashton Pooley",
8
8
  author_email="Ashton@ashi.digital",
@@ -1,6 +1,8 @@
1
1
  from datetime import datetime
2
+ import time
2
3
  import re
3
- from smartsheet.models import Cell, Row, Folder, Sheet
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.7
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>