Attempt to parse a Treeview value to its appropriate Python data type. The priority order of parsing is: JSON, number, boolean, string.
(self, value)
| 225 | return reconstructed_data |
| 226 | |
| 227 | def parse_treeview_value(self, value): |
| 228 | """ |
| 229 | Attempt to parse a Treeview value to its appropriate Python data type. |
| 230 | The priority order of parsing is: JSON, number, boolean, string. |
| 231 | """ |
| 232 | # Try parsing as JSON |
| 233 | try: |
| 234 | return json.loads(value) |
| 235 | except (json.JSONDecodeError, TypeError): |
| 236 | pass |
| 237 | |
| 238 | # Try parsing as an integer |
| 239 | try: |
| 240 | return int(value) |
| 241 | except ValueError: |
| 242 | pass |
| 243 | |
| 244 | # Try parsing as a float |
| 245 | try: |
| 246 | return float(value) |
| 247 | except ValueError: |
| 248 | pass |
| 249 | |
| 250 | # Try parsing as a boolean |
| 251 | lowered_value = value.lower() |
| 252 | if lowered_value in ('true', 'false'): |
| 253 | return lowered_value == 'true' |
| 254 | |
| 255 | # If all else fails, return as string |
| 256 | return value |
| 257 | |
| 258 | |
| 259 | def get_last_entry(self): |