smartsheet-tools 0.0.5__tar.gz → 0.0.7__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.5
3
+ Version: 0.0.7
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.5" # from setup.py
7
+ version = "0.0.7" # 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.5",
5
+ version="0.0.7",
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",
@@ -55,17 +55,27 @@ def standard_time_to_isoformat(st):
55
55
  return None
56
56
  return datetime_to_isoformat(datetime.strptime(st, "%m/%d/%Y"))
57
57
 
58
- def get_cached_column_type(column_id, sheet_obj):
58
+ def get_cached_column_type(column_id, sheet_obj, prefill=False):
59
59
  if sheet_obj.id not in _COLUMN_TYPE_CACHE:
60
60
  _COLUMN_TYPE_CACHE[sheet_obj.id] = {}
61
61
 
62
62
  if column_id not in _COLUMN_TYPE_CACHE[sheet_obj.id]:
63
- _COLUMN_TYPE_CACHE[sheet_obj.id][column_id] = str(sheet_obj.get_column(column_id).type)
63
+ if not prefill:
64
+
65
+ # Value is not in there and no prefill, so look it up
66
+ for col in sheet_obj.columns:
67
+ _COLUMN_TYPE_CACHE[sheet_obj.id][column_id] = col.type
68
+
69
+ else:
70
+ _COLUMN_TYPE_CACHE[sheet_obj.id][column_id] = prefill
64
71
 
65
72
  return _COLUMN_TYPE_CACHE[sheet_obj.id][column_id]
66
73
 
67
74
  def get_col_names_of_date_cols(sheet_obj):
68
- return [c.title for c in sheet_obj.columns if get_cached_column_type(c.id, sheet_obj) in ("DATE", "DATETIME")]
75
+ return [c.title for c in sheet_obj.columns if get_cached_column_type(c.id, sheet_obj, prefill=c.type) in ("DATE", "DATETIME")]
76
+
77
+ def get_col_names_of_bool_cols(sheet_obj):
78
+ return [c.title for c in sheet_obj.columns if get_cached_column_type(c.id, sheet_obj, prefill=c.type) == "CHECKBOX"]
69
79
 
70
80
  def brute_force_date_string(s, nonetype_if_fail=False):
71
81
  # attempt to parse a date string in common formats to ISO 8601
@@ -88,16 +98,16 @@ def is_date_col(column_id, sheet_obj):
88
98
  column_type = get_cached_column_type(column_id, sheet_obj)
89
99
  return column_type in ("DATE", "DATETIME")
90
100
 
91
- def correct_date_format(isoformat_datetime, column_id, sheet_obj):
92
- if isinstance(isoformat_datetime, datetime):
93
- isoformat_datetime = datetime_to_isoformat(isoformat_datetime)
101
+ def correct_date_format(value, column_id, sheet_obj, nonetype_if_fail=False):
102
+ if isinstance(value, datetime):
103
+ value = datetime_to_isoformat(value)
94
104
 
95
105
  column_type = get_cached_column_type(column_id, sheet_obj)
96
106
  if column_type == "DATE":
97
- return isoformat_datetime.split("T",1)[0]
107
+ return value.split("T",1)[0]
98
108
  elif column_type == "DATETIME":
99
- return isoformat_datetime
100
- return None
109
+ return value
110
+ return None if nonetype_if_fail else value
101
111
 
102
112
  def new_cell(column_id=None, value=None, strict=False, formula=None):
103
113
  new_cell = Cell()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: smartsheet_tools
3
- Version: 0.0.5
3
+ Version: 0.0.7
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>