Drafts Module Reference

New in version 0.0.8.

Control Drafts using JXA-like syntax.

Classes:

XADraftsApplication(properties)

A class for managing and interacting with Drafts.app.

XADraftsDraft(properties)

A draft in Drafts.app.

XADraftsDraftList(properties[, filter])

A wrapper around a list of drafts.

class PyXA.apps.Drafts.XADraftsApplication(properties)[source]

Bases: XASBApplication, XACanOpenPath

A class for managing and interacting with Drafts.app.

New in version 0.0.8.

Classes:

ObjectType(value)

Object types that can be created using XADraftsApplication.make().

Methods:

drafts([filter])

Returns a list of drafts, as PyXA-wrapped objects, matching the given filter.

make(specifier[, properties, data])

Creates a new element of the given specifier class without adding it to any list.

new_draft(content)

Creates a new draft with the given name and content

Attributes:

name

The name of the application.

version

The version of Drafts.app.

class ObjectType(value)[source]

Bases: Enum

Object types that can be created using XADraftsApplication.make().

Attributes:

DRAFT

DRAFT = 'draft'
drafts(filter: dict | None = None) XADraftsDraftList[source]

Returns a list of drafts, as PyXA-wrapped objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter drafts by, defaults to None

Returns:

A PyXA list object wrapping a list of drafts

Return type:

XADraftsDraftList

New in version 0.0.8.

make(specifier: str | ObjectType, properties: dict | None = None, data: Any | None = None)[source]

Creates a new element of the given specifier class without adding it to any list.

Use XABase.XAList.push() to push the element onto a list.

Parameters:
  • specifier (Union[str, XADraftsApplication.ObjectType]) – The classname of the object to create

  • properties (dict) – The properties to give the object

  • data (Any, optional) – The data to initialize the object with, defaults to None

Returns:

A PyXA wrapped form of the object

Return type:

XABase.XAObject

New in version 0.0.8.

property name: str

The name of the application.

new_draft(content: str) XADraftsDraft[source]

Creates a new draft with the given name and content

Parameters:

content (str) – The full content of the draft (the first line is the name)

Returns:

The newly created draft object

Return type:

XADraftsDraft

New in version 0.0.8.

property version: str

The version of Drafts.app.

class PyXA.apps.Drafts.XADraftsDraft(properties)[source]

Bases: XAObject

A draft in Drafts.app.

New in version 0.0.8.

Attributes:

accessed_at

The date the draft was last accessed.

content

The content of the draft.

created_at

The date the draft was created.

flagged

The flagged status of the draft.

id

The unique identifier of the draft.

modified_at

The date the draft was last modified.

name

The first line of the draft.

permalink

The URL of the draft.

tags

The tags assigned to the draft.

property accessed_at: datetime

The date the draft was last accessed.

property content: str

The content of the draft.

property created_at: datetime

The date the draft was created.

property flagged: bool

The flagged status of the draft.

property id: str

The unique identifier of the draft.

property modified_at: datetime

The date the draft was last modified.

property name: str

The first line of the draft.

The URL of the draft.

property tags: list[str]

The tags assigned to the draft.

class PyXA.apps.Drafts.XADraftsDraftList(properties: dict, filter: dict | None = None)[source]

Bases: XAList

A wrapper around a list of drafts.

New in version 0.0.8.

Methods:

accessed_at()

by_accessed_at(accessed_at)

by_content(content)

by_created_at(created_at)

by_flagged(flagged)

by_id(id)

by_modified_at(modified_at)

by_name(name)

by_permalink(permalink)

by_tags(tags)

content()

created_at()

flagged()

id()

modified_at()

name()

permalink()

tags()

accessed_at() list[datetime][source]
by_accessed_at(accessed_at: datetime) XADraftsDraft | None[source]
by_content(content: str) XADraftsDraft | None[source]
by_created_at(created_at: datetime) XADraftsDraft | None[source]
by_flagged(flagged: bool) XADraftsDraft | None[source]
by_id(id: str) XADraftsDraft | None[source]
by_modified_at(modified_at: datetime) XADraftsDraft | None[source]
by_name(name: str) XADraftsDraft | None[source]
by_tags(tags: list[str]) XADraftsDraft | None[source]
content() list[str][source]
created_at() list[datetime][source]
flagged() list[bool][source]
id() list[str][source]
modified_at() list[datetime][source]
name() list[str][source]
tags() list[list[str]][source]