mlsync.consumers.notion package

Submodules

mlsync.consumers.notion.notion_api module

class mlsync.consumers.notion.notion_api.NotionAPI(token, version='v3')

Bases: object

An API for Notion.

token

A token to access Notion.

Type

str

version

The version of the API to use.

Type

str

addPageToDatabase(database_id, properties)

Add a page to a database.

Parameters
  • database_id (str) – The id of the database.

  • properties (dict) – The properties of the page.

createDatabase(name, properties, parent_id)

Create a new database.

Parameters
  • name (str) – The name of the database.

  • properties (dict) – The properties of the database.

  • parent_id (str) – The id of the parent page.

deletePageFromDatabase(database_id, page_id, properties)

Delete a page from a database by archiving.

Parameters
  • database_id (str) – The id of the database.

  • page_id (str) – The id of the page.

  • properties (dict) – The properties of the page.

getAllDatabases()

Get all databases.

getDatabase(database_id)

Get a database.

Parameters

database_id (str) – The id of the database.

readDatabase(database_id)

Read a database.

Parameters

database_id (str) – The id of the database.

readPage(page_id)

Read a page in a database.

Parameters

page_id (str) – The id of the page to read.

search(query='', filter=None)

Search for a page.

Parameters
testPageAccess(page_id)

Test if a page can be accessed.

Parameters

page_id (str) – The id of the page to test.

updateDatabase(database_id, properties)

Update a database.

Parameters
  • database_id (str) – The id of the database.

  • properties (dict) – The properties of the database.

updatePageInDatabase(database_id, page_id, properties)

Update a page in a database.

Parameters
  • database_id (str) – The id of the database.

  • page_id (str) – The id of the page.

  • properties (dict) – The properties of the page.

mlsync.consumers.notion.notion_formatter module

class mlsync.consumers.notion.notion_formatter.NotionFormatter(notion_api, report_format)

Bases: object

Converts reports into Notion’s formats.

create_notion_property(property_type, metadata)

Create a Notion property for a given property type and name.

Parameters
  • property_type (str) – The type of the property.

  • metadata (dict) – The metadata of the property.

format_in(notion_report, root_page_id)

Converts current Notion report and converts it to MLSync report.

Parameters

notion_report (dict) – The Notion report as obtained from the Notion API.

format_out(report)

Convert mlsync report into a Notion table.

Parameters

report (dict) – The mlsync report. Format is derived from the report format file.

get_notion_property(property_type, metadata)

Get the Notion property for a given property type and name.

Parameters
  • property_type (str) – The type of the property.

  • metadata (dict) – The metadata of the property.

notion_property_type_conversion(val_type)

Convert the type of a property to a Notion type.

Parameters

val_type (str) – The type of the property.

read_notion_property(property_object)

Read Notion property from its quirky format to a readable format.

Parameters

property_object (dict) – The Notion property.

mlsync.consumers.notion.notion_sync module

class mlsync.consumers.notion.notion_sync.NotionSync(notion_token: str, root_page_id: str, report_format: dict)

Bases: object

Sync data from mlsync to Notion.

Parameters
  • notion_api (NotionAPI) – The Notion API object.

  • root_page_id (str) – The root page id

pull()

Fetch the current state of the Notion page and return report in mlsync format.

push(report, command='new', diff_report=None)

Takes current MLSync report and syncs it with Notion.

Parameters
  • report (dict) – MLSync report

  • command (str) – The command to execute, It can be “new”, “create”, “update” or “delete”

  • diff_report (dict) – The diff report describing the changes to be made.

mlsync.consumers.notion.page_picker module

mlsync.consumers.notion.page_picker.pageTitle(page)

Get page title.

Parameters

page (dict) – Page properties.

mlsync.consumers.notion.page_picker.pick_page(token)

Helper function to pick a page from Notion

Parameters

token (str) – Notion token

Module contents