Skip to main content

A wrapper for the smartsheet-python-sdk that monkey-patches in new methods & functionality.

Project description

Smartools

smartools is a wrapper around the official smartsheet-python-sdk. It monkey patches several classes to add new functionality, and also implements some completely new classes/models as well.

The decision was made to monkey patch the smartsheet sdk rather than fork it because by extending the existing package, this package can be updated independently of the original sdk and sis not dependent on a specific version.

Installation

The package is available to install from PyPi using:

pip install smartools

Once installed it can be imported with import smartools or can more "authentically" replace the official sdk by using import smartools as smartsheet

Usage

In general, usage of smartools is identical to the standard SDK. All original functionality is supported so any existing code should not need to be updated. For more information, see the Smartsheet API Docs.

Extended/Improved Functionality

Comparison of sharing permissions

smartools allows you to easily compare sharing permissions using the standard >, <, >=, >=, == methods. This can be useful when writing code that will evaluate whether a user has high enough permissions to perform an action. Smartools also has added support for the COMMENTER permission level. It also includes a new permission level, "UNSHARED" that can be used for comparisons. That permission level simply indicates that somethng isn't shared to you, and is only ever returned when using a get_access_level method.

sheet = smartsheet_client.Sheets.get_sheet(sheet_id)

sheet.access_level                 # EDITOR_SHARE
sheet.access_level >= 'EDITOR'     # True
sheet.access_level == 'OWNER'      # False
sheet.access_level > 'EDITOR'      # True
sheet.access_level != 'UNSHARED'   # True - This is a new "permission level" exclusive to smartools

Easily Retrieve Child Rows

Rows now allow you to get their child rows by accessing row.children.

sheet = smartsheet_client.Sheets.get_sheet(sheet_id)

sheet.rows[0].children  # Will return a list of child rows

Indexing sheets/reports

Some of the greatest improvements to smartools are in the indexing of lists. Rows, Columns, and Cells can now be indexed using strings, as explained below.

Columns

Index a list of columns by utilizing the column name. You can also find the primary column with an empty string ''. Indexing with integers (based on positioning) is still possible.

sheet = smartshet_client.Sheets.get_sheet(sheet_id)

sheet.columns['Date'].type  # DATE
sheet.columns[''].primary   # True
sheet.columns[3].title      # Column4

Rows

Indexing rows can be done utilizing the primary column value. Indexing with integers is still possible.

NOTE: If multiple rows have the same primary column value, the first row with this value will be returned. If indexing with an empty string '' the first row with no primary column value will be returned.

sheet = smartsheet_client.Sheets.get_sheet(sheetid)

sheet.rows['Task Name'].id  # 12345678910

Cells

Indexing a list of cells can be done utilizing column names. Indexing with integers is still possible.

NOTE: Indexing this way is only possible in requests where columns have been obtained, such as when getting a sheet or report, but will not work if columns are not included in the response, such as when getting a row.

sheet = smartsheet_client.Sheets.get_sheet(sheetid)

sheet.rows['Phase 1'].cells['Start Date'].value  # 01/01/20222

Getting Forms

Calling get_sheet with include='publishedFormContainers' will now include basic form information (such as its permalink) with the sheet.

Brand New Functionality

Cell Formatting

smartools includes a CellFormat model that allows you to apply formatting in a more user-friendly way. To use this, create a CellFormat object and update its various properties, such as font_family, thousands_separator, etc. A short usage example can be seen below, and a full list of all the properties that can be updated can be found here.

formatting = smartsheet.models.CellFormat()
formatting.font_type = 'TAHOMA'
formatting.font_size = 'TWELVE'
formatting.bold = 1  # Will apply the "1" setting of legacy formatting management using strings, which is "ON"

new_row = smartsheet.models.Row()
new_row.cells.append({
    'column_id': 12345678910,
    'value': 'My Value',
    'format': formatting,
})
new_row.cells.append({
    'column_id': 23456789101,
    'value': 'My Other Value',
    'format': smartsheet.models.CellFormat({
        'italic': 'ON',
        'strikethrough': 'ON',
        'background_color': 'FFFEE6',
    })
})

smartsheet_client.Sheets.add_rows(sheet_id, new_row)

New methods

Several new methods have been added to the various classes within the smartsheet_client, these are listed below and documented in more detail within their respective docs.

Sheets

  • Sheets.bulk_add_rows
  • Sheets.bulk_update_rows
  • Sheets.bulk_delete_rows
  • Sheets.get_access_level

Reports

  • Reports.update_report
  • Reports.move_report
  • Reports.get_large_report
  • Reports.get_access_level

Home

  • Home.get_container_from_url
  • Home.create_sight
  • Home.create_report

Folders

  • Folders.list_sheets_in_folder
  • Folders.list_containers_in_folder
  • Folders.get_access_level
  • Folders.create_sight_in_folder
  • Folders.create_report_in_folder

Workspaces

  • Workspaces.list_sheets_in_workspace
  • Workspaces.list_containers_in_workspace
  • Workspaces.get_access_level
  • Workspaces.create_sight_in_workspace
  • Workspaces.create_report_in_workspace

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartools-1.2.0.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

smartools-1.2.0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file smartools-1.2.0.tar.gz.

File metadata

  • Download URL: smartools-1.2.0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for smartools-1.2.0.tar.gz
Algorithm Hash digest
SHA256 9da1a70dae89fbddc9ade8fce285cf31296773bf86ddc960d9288d5de8bad72b
MD5 9aab633f9c3a9364a8e38d9292488662
BLAKE2b-256 94ac74464d2e16a12bbb4ffef93de6c93f7a0b57c8bebf673d1c29e3ff5e7c5e

See more details on using hashes here.

File details

Details for the file smartools-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: smartools-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for smartools-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0dd9211a808df3727c0ade14892e5d5e1d05057ddaabc01c10c3cc66f9af0fe9
MD5 2245427d99889c2d42bdb21bbcf244fc
BLAKE2b-256 a01afd1013400e869125116bb3adea39a4f6b6c447e42e49330cc2e3cd58b99d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page