Numbers Module Reference
New in version 0.0.1.
Control the macOS Notes application using JXA-like syntax.
Classes:
|
A class for interacting with notes in the Notes application. |
|
A class for interacting with attachments in the Notes application. |
|
A wrapper around a list of notes. |
|
A class for interacting with accounts in the Notes application. |
|
A wrapper around a list of accounts. |
|
A class for interacting with Notes.app. |
|
A wrapper around a list of attachments. |
|
A class for interacting with documents in Notes.app. |
|
A wrapper around a list of documents. |
|
A class for interacting with Notes folders and their contents. |
|
A wrapper around a list of Notes folders. |
|
A window of Notes.app. |
- class PyXA.apps.Notes.XANote(properties)[source]
Bases:
XAObject
,XAClipboardCodable
,XAShowable
,XADeletable
A class for interacting with notes in the Notes application.
See also
Changed in version 0.0.3: Added
show()
andshow_separately()
New in version 0.0.1.
Methods:
attachments
([filter])Returns a list of attachments, as PyXA objects, matching the given filter.
Gets a clipboard-codable representation of the note.
move_to
(folder)Moves the note to the specified folder.
show
()Shows the note in the main Notes window.
Shows the note in a separate window.
Attributes:
The HTML content of the note.
The folder that the note is in.
The date and time the note was created.
The unique identifier for the note.
The date and time the note was last modified.
The name of the note (generally the first line of the body).
Whether the note is password protected.
The plaintext content of the note.
Whether the note is shared.
- attachments(filter: dict | None = None) XANotesAttachmentList [source]
Returns a list of attachments, as PyXA objects, matching the given filter.
- Parameters:
filter (dict, optional) – Keys and values to filter attachments by, defaults to None
- Returns:
A PyXA list object wrapping a list of attachments
- Return type:
- Example 1:
List all attachments of a note
>>> import PyXA >>> app = PyXA.Application("Notes") >>> note = app.notes()[-4] >>> print(note.attachments()) <<class 'PyXA.apps.Notes.XANotesAttachmentList'>[('Example.pdf, 'x-coredata://224D909C-B449-42B0-96EC-380EE22332E2/ICAttachment/p526')]>
- Example 2:
Save the attachments of a note to the Downloads folder
>>> import PyXA >>> app = PyXA.Application("Notes") >>> note = app.notes()[0] >>> print(note.attachments().save("/Users/exampleuser/Downloads/"))
Changed in version 0.0.3: Now returns an object of
XANotesAttachmentList
instead of a default list.New in version 0.0.1.
- property body: str
The HTML content of the note.
- property container: XANotesFolder
The folder that the note is in.
- property creation_date: datetime
The date and time the note was created.
- get_clipboard_representation() str [source]
Gets a clipboard-codable representation of the note.
When the clipboard content is set to a note, the plaintext representation of the note is added to the clipboard.
- Returns:
The plaintext representation of the note
- Return type:
str
New in version 0.0.8.
- property id: str
The unique identifier for the note.
- property modification_date: datetime
The date and time the note was last modified.
- move_to(folder: XANotesFolder) XANote [source]
Moves the note to the specified folder.
- Parameters:
folder (XANotesFolder) – The folder to move the note to
- Returns:
A reference to the note object
- Return type:
New in version 0.0.4.
- property name: str
The name of the note (generally the first line of the body).
- property password_protected: bool
Whether the note is password protected.
- property plaintext: str
The plaintext content of the note.
Whether the note is shared.
- class PyXA.apps.Notes.XANoteAttachment(properties)[source]
Bases:
XAObject
,XAClipboardCodable
A class for interacting with attachments in the Notes application.
Changed in version 0.0.3: Added
show()
andshow_separately()
New in version 0.0.1.
Attributes:
The note containing the attachment.
The content ID of the attachment in the note's HTML.
The date the attachment was created.
The unique identifier for the attachment.
The date the attachment was last modified.
The name of the attachment.
Whether the attachment is shared.
The URL that the attachment represents, if any.
Methods:
delete
()Permanently deletes the attachment.
Gets a clipboard-codable representation of the attachment.
save
(directory)Saves the attachment to the specified directory.
show
()Shows the attachment in the main Notes window.
Shows the attachment in a separate window.
- property content_identifier: str
The content ID of the attachment in the note’s HTML.
- property creation_date: datetime
The date the attachment was created.
- get_clipboard_representation() str | list[NSURL | str] [source]
Gets a clipboard-codable representation of the attachment.
When the clipboard content is set to an attachment, the URL of the attachment (if one exists) and the attachment’s name are added to the clipboard.
- Returns:
The URL and name of the attachment, or just the name of the attachment
- Return type:
list[Union[AppKit.NSURL, str]]
New in version 0.0.8.
- property id: str
The unique identifier for the attachment.
- property modification_date: datetime
The date the attachment was last modified.
- property name: str
The name of the attachment.
- save(directory: str) XANoteAttachment [source]
Saves the attachment to the specified directory.
- Parameters:
directory (str) – The directory to store the saved attachment in
- Returns:
A reference to the attachment object
- Return type:
New in version 0.0.4.
Whether the attachment is shared.
- show() XANoteAttachment [source]
Shows the attachment in the main Notes window.
- Returns:
A reference to the attachment object
- Return type:
New in version 0.0.3.
- show_separately() XANoteAttachment [source]
Shows the attachment in a separate window.
- Returns:
A reference to the attachment object
- Return type:
New in version 0.0.3.
- class PyXA.apps.Notes.XANoteList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
,XAClipboardCodable
A wrapper around a list of notes.
New in version 0.0.3.
Methods:
body
()by_body
(body)by_container
(container)by_creation_date
(creation_date)by_id
(id)by_modification_date
(modification_date)by_name
(name)by_password_protected
(password_protected)by_plaintext
(plaintext)by_shared
(shared)Gets a clipboard-codable representation of each note in the list.
id
()name
()shared
()Shows each note in the list in a separate window.
- attachments() XANotesAttachmentList [source]
- by_container(container: XANotesFolder) XANote [source]
- container() XANotesFolderList [source]
- get_clipboard_representation() list[str] [source]
Gets a clipboard-codable representation of each note in the list.
When the clipboard content is set to a list of notes, the plaintext of each note is added to the clipboard.
- Returns:
A list of note plaintext representations
- Return type:
list[str]
New in version 0.0.8.
- show_separately() XANoteList [source]
Shows each note in the list in a separate window.
- Example 1:
Show the currently selected notes in separate windows
>>> import PyXA >>> app = PyXA.Application("Notes") >>> notes = app.selection.show_separately()
New in version 0.0.4.
- class PyXA.apps.Notes.XANotesAccount(properties)[source]
Bases:
XAObject
,XAClipboardCodable
A class for interacting with accounts in the Notes application.
Changed in version 0.0.3: Added
show()
New in version 0.0.1.
Attributes:
The default folder for creating new notes.
The unique identifier of the account.
The name of the account.
Whether the account is upgraded.
Methods:
folders
([filter])Returns a list of folders, as PyXA objects, matching the given filter.
Gets a clipboard-codable representation of the account.
notes
([filter])Returns a list of notes, as PyXA objects, matching the given filter.
show
()Shows the first folder belonging to the account.
- property default_folder: XANotesFolder
The default folder for creating new notes.
- folders(filter: dict | None = None) XANotesFolderList [source]
Returns a list of folders, as PyXA objects, matching the given filter.
- Parameters:
filter (dict, optional) – Keys and values to filter folders by, defaults to None
- Returns:
A PyXA list object wrapping a list of folders
- Return type:
- Example 1:
List all folders belonging to an account
>>> import PyXA >>> app = PyXA.Application("Notes") >>> account = app.accounts()[0] >>> print(account.folders()) <<class 'PyXA.apps.Notes.XANotesFolderList'>[('Imported Notes', 'x-coredata://224D909C-B449-42B0-96EC-380EE22332E2/ICFolder/p3104'), ('Notes', 'x-coredata://224D909C-B449-42B0-96EC-380EE22332E2/ICFolder/p3123'), ...]>
Changed in version 0.0.3: Now returns an object of
XANotesFolderList
instead of a default list.New in version 0.0.1.
- get_clipboard_representation() str [source]
Gets a clipboard-codable representation of the account.
When the clipboard content is set to an account, the account’s name are added to the clipboard.
- Returns:
The name of the account
- Return type:
str
New in version 0.0.8.
- property id: str
The unique identifier of the account.
- property name: str
The name of the account.
- notes(filter: dict | None = None) XANoteList [source]
Returns a list of notes, as PyXA objects, matching the given filter.
- Parameters:
filter (dict, optional) – Keys and values to filter notes by, defaults to None
- Returns:
A PyXA list object wrapping a list of notes
- Return type:
- Example 1:
List all notes belonging to an account
>>> import PyXA >>> app = PyXA.Application("Notes") >>> account = app.accounts()[0] >>> print(account.notes()) <<class 'PyXA.apps.Notes.XANoteList'>[('PyXA Stuff', 'x-coredata://224D909C-B449-42B0-96EC-380EE22332E2/ICNote/p3380'), ('Important Note', 'x-coredata://224D909C-B449-42B0-96EC-380EE22332E2/ICNote/p614'), ...]>
Changed in version 0.0.3: Now returns an object of
XANoteList
instead of a default list.New in version 0.0.1.
- show() XANotesAccount [source]
Shows the first folder belonging to the account.
- Returns:
A reference to the account object
- Return type:
New in version 0.0.3.
- property upgraded: bool
Whether the account is upgraded.
- class PyXA.apps.Notes.XANotesAccountList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
,XAClipboardCodable
A wrapper around a list of accounts.
New in version 0.0.3.
Methods:
by_default_folder
(default_folder)by_id
(id)by_name
(name)by_upgraded
(upgraded)folders
()Gets a clipboard-codable representation of each account in the list.
id
()name
()notes
()upgraded
()- by_default_folder(default_folder: XANotesFolder) XANotesAccount [source]
- by_id(id: str) XANotesAccount [source]
- by_name(name: str) XANotesAccount [source]
- by_upgraded(upgraded: bool) XANotesAccount [source]
- default_folder() XANotesFolderList [source]
- folders() XANotesFolderList [source]
- get_clipboard_representation() list[str] [source]
Gets a clipboard-codable representation of each account in the list.
When the clipboard content is set to a list of accounts, the name of each account is added to the clipboard.
- Returns:
A list of account names
- Return type:
list[str]
New in version 0.0.8.
- notes() XANoteList [source]
- class PyXA.apps.Notes.XANotesApplication(properties)[source]
Bases:
XASBApplication
,XACanOpenPath
,XACanPrintPath
A class for interacting with Notes.app.
See also
Changed in version 0.0.3: Added
accounts()
,attachments()
, and related methodsNew in version 0.0.1.
Classes:
FileFormat
(value)An enumeration.
ObjectType
(value)Types of objects that can be created using
make()
.Methods:
accounts
([filter])Returns a list of Notes accounts, as PyXA objects, matching the given filter.
attachments
([filter])Returns a list of attachments, as PyXA objects, matching the given filter.
documents
([filter])Returns a list of documents, as PyXA objects, matching the given filter.
folders
([filter])Returns a list of Notes folders, as PyXA 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_folder
([name, account])Creates a new Notes folder with the given name.
new_note
([name, body, folder])Creates a new note with the given name and body text in the given folder.
notes
([filter])Returns a list of notes, as PyXA objects, matching the given filter.
open
(file_ref)Opens the file/website at the given filepath/URL.
Attributes:
The account that new notes are created in by default.
Whether Notes is the active application.
The name of the application.
A list of currently selected notes.
The version number of Notes.app.
- class FileFormat(value)[source]
Bases:
Enum
An enumeration.
Attributes:
The native Notes format
- NATIVE = 1769235821
The native Notes format
- class ObjectType(value)[source]
Bases:
Enum
Types of objects that can be created using
make()
.Attributes:
- ACCOUNT = 'account'
- ATTACHMENT = 'attachment'
- FOLDER = 'folder'
- NOTE = 'note'
- accounts(filter: dict | None = None) XANotesAccountList [source]
Returns a list of Notes accounts, as PyXA objects, matching the given filter.
New in version 0.0.3.
- attachments(filter: dict | None = None) XANotesAttachmentList [source]
Returns a list of attachments, as PyXA objects, matching the given filter.
New in version 0.0.3.
- property default_account: XANotesAccount
The account that new notes are created in by default.
- documents(filter: dict | None = None) XANotesDocumentList [source]
Returns a list of documents, as PyXA objects, matching the given filter.
New in version 0.0.3.
- folders(filter: dict | None = None) XANotesFolderList [source]
Returns a list of Notes folders, as PyXA objects, matching the given filter.
- Example 1:
Retrieve the name of each folder
>>> import PyXA >>> app = PyXA.Application("Notes") >>> print(app.folders().name()) ['ExampleFolder1', 'ExampleFolder2', 'ExampleFolder3', ...]
Changed in version 0.0.3: Now returns an object of
XANotesFolderList
instead of a default list.New in version 0.0.1.
- property frontmost: bool
Whether Notes is the active application.
- make(specifier: str | ObjectType, properties: dict | None = None, data: XAPath | str | 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, XANotesApplication.ObjectType]) – The classname of the object to create
properties (dict) – The properties to give the object
- Returns:
A PyXA wrapped form of the object
- Return type:
- Example 1:
Make a new folder and add a new note to that folder
>>> import PyXA >>> app = PyXA.Application("Notes") >>> new_folder = app.make("folder", {"name": "Example Folder"}) >>> new_note = app.make("note", {"name": "Example Note"}) >>> app.folders().push(new_folder) >>> new_folder.notes().push(new_note)
New in version 0.0.3.
- property name: str
The name of the application.
- new_folder(name: str = 'New Folder', account: XANotesAccount | None = None) XANotesFolder [source]
Creates a new Notes folder with the given name.
- Parameters:
name (str, optional) – The name of the folder, defaults to “New Folder”
- Returns:
A reference to the newly created folder.
- Return type:
- Example:
>>> import PyXA >>> app = PyXA.Application("Notes") >>> folder = app.new_folder("PyXA Notes Folder") >>> print(folder) <<class 'PyXA.apps.Notes.XANotesFolder'>PyXA Notes Folder, x-coredata://224D909C-B449-42B0-96EC-380EE22332E2/ICFolder/p3389>
See also
New in version 0.0.1.
- new_note(name: str = 'New Note', body: str | XAText = '', folder: XANotesFolder | None = None) XANote [source]
Creates a new note with the given name and body text in the given folder. If no folder is provided, the note is created in the default Notes folder.
- Parameters:
name (str, optional) – The name of the note, defaults to “New Note”
body (str, optional) – The initial body text of the note, defaults to “”
folder (XANotesFolder, optional) – The folder to create the new note in, defaults to None
- Returns:
A reference to the newly created note.
- Return type:
- Example:
>>> import PyXA >>> app = PyXA.Application("Notes") >>> note = app.new_note("PyXA Notes", "Example text of new note.") >>> print(note) <<class 'PyXA.apps.Notes.XANote'>PyXA Notes, x-coredata://224D909C-B449-42B0-96EC-380EE22332E2/ICNote/p3388>
See also
New in version 0.0.1.
- notes(filter: dict | None = None) XANoteList [source]
Returns a list of notes, as PyXA objects, matching the given filter.
- Parameters:
filter (dict, optional) – Keys and values to filter notes by, defaults to None
- Returns:
A PyXA list object wrapping a list of notes
- Return type:
- Example 1:
Retrieve the name of each note
>>> import PyXA >>> app = PyXA.Application("Notes") >>> print(app.notes().name()) ['ExampleName1', 'ExampleName2', 'ExampleName3', ...]
- Example 2:
Retrieve notes by using a filter
>>> import PyXA >>> app = PyXA.Application("Notes") >>> print(app.notes().containing("name", "fancy")) [('ExampleName1', 'x-coredata://213D109C-B439-42A0-96EC-380DE31393E2/ICNote/p2964'), ('ExampleName11', 'x-coredata://213D109C-B439-42A0-96EC-380DE31393E2/ICNote/p2963'), ...]
- Example 3:
Iterate over each note
>>> import PyXA >>> app = PyXA.Application("Notes") >>> for note in app.notes(): >>> print(note.name) ExampleName1 ExampleName2 ExampleName3 ...
Changed in version 0.0.3: Now returns an object of
XANoteList
instead of a default list.New in version 0.0.1.
- open(file_ref: XAPath | str) XANote [source]
Opens the file/website at the given filepath/URL.
Child classes of XACanOpenPath should redefine this method as necessary.
- Parameters:
target (str) – The path to a file or the URL to a website to open.
- Returns:
A reference to the opened document or element, or None if no document/element was created or it cannot be found
- Return type:
Any
New in version 0.0.1.
- property selection: XANoteList
A list of currently selected notes.
- property version: str
The version number of Notes.app.
- class PyXA.apps.Notes.XANotesAttachmentList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
,XAClipboardCodable
A wrapper around a list of attachments.
New in version 0.0.3.
Methods:
by_container
(container)by_content_identifier
(content_identifier)by_creation_date
(creation_date)by_id
(id)by_modification_date
(modification_date)by_name
(name)by_shared
(shared)by_url
(url)id
()name
()save
(directory)Saves all attachments in the list in the specified directory.
shared
()url
()- by_container(container: XANote) XANoteAttachment | None [source]
- by_content_identifier(content_identifier: str) XANoteAttachment | None [source]
- by_creation_date(creation_date: datetime) XANoteAttachment [source]
- by_id(id: str) XANoteAttachment | None [source]
- by_modification_date(modification_date: datetime) XANoteAttachment | None [source]
- by_name(name: str) XANoteAttachment | None [source]
- by_url(url: str | XAURL) XANoteAttachment | None [source]
- container() XANoteList [source]
- save(directory: str) XANotesAttachmentList [source]
Saves all attachments in the list in the specified directory.
- Parameters:
directory (str) – The directory to store the saved attachments in
- Returns:
A reference to the attachment list object
- Return type:
- Example 1:
Save the attachments in currently selected notes to the downloads folder
>>> import PyXA >>> app = PyXA.Application("Notes") >>> app.selection.attachments().save("/Users/exampleuser/Downloads/")
New in version 0.0.4.
- class PyXA.apps.Notes.XANotesDocument(properties)[source]
Bases:
XAObject
,XAClipboardCodable
A class for interacting with documents in Notes.app.
New in version 0.0.3.
Attributes:
The location of the document on the disk, if one exists.
Whether the document has been modified since the last save.
The name of the document.
Methods:
Gets a clipboard-codable representation of the document.
- property file: str
The location of the document on the disk, if one exists.
- get_clipboard_representation() str [source]
Gets a clipboard-codable representation of the document.
When the clipboard content is set to a document, the document’s name is added to the clipboard.
- Returns:
The name of the document
- Return type:
str
New in version 0.0.8.
- property modified: bool
Whether the document has been modified since the last save.
- property name: str
The name of the document.
- class PyXA.apps.Notes.XANotesDocumentList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
,XAClipboardCodable
A wrapper around a list of documents.
New in version 0.0.3.
Methods:
by_file
(file)by_modified
(modified)by_name
(name)file
()Gets a clipboard-codable representation of each document in the list.
modified
()name
()- by_file(file: str) XANotesDocument [source]
- by_modified(modified: bool) XANotesDocument [source]
- by_name(name: str) XANotesDocument [source]
- get_clipboard_representation() list[str] [source]
Gets a clipboard-codable representation of each document in the list.
When the clipboard content is set to a list of documents, the name of each document is added to the clipboard.
- Returns:
A list of document names
- Return type:
list[str]
New in version 0.0.8.
- class PyXA.apps.Notes.XANotesFolder(properties)[source]
Bases:
XAObject
,XAClipboardCodable
A class for interacting with Notes folders and their contents.
See also
class:XANote
Changed in version 0.0.3: Added
show()
New in version 0.0.1.
Attributes:
The account the folder belongs to.
The unique identifier for the folder.
The name of the folder.
Whether the folder is shared.
Methods:
delete
()Permanently deletes the folder.
folders
([filter])Returns a list of folders, as PyXA objects, matching the given filter.
Gets a clipboard-codable representation of the folder.
move_to
(destination)Moves the folder to the specified container.
notes
([filter])Returns a list of notes, as PyXA objects, matching the given filter.
show
()Shows the folder in the main Notes window.
- property container: XANotesAccount
The account the folder belongs to.
- folders(filter: dict | None = None) XANotesFolderList [source]
Returns a list of folders, as PyXA objects, matching the given filter.
- Parameters:
filter (dict, optional) – Keys and values to filter folders by, defaults to None
- Returns:
A PyXA list object wrapping a list of folders
- Return type:
New in version 0.2.0.
- get_clipboard_representation() str [source]
Gets a clipboard-codable representation of the folder.
When the clipboard content is set to a notes folder, the name of the folder is added to the clipboard.
- Returns:
The name of the notes folder
- Return type:
str
New in version 0.0.8.
- property id: str
The unique identifier for the folder.
- move_to(destination: XANotesFolder | XANotesAccount) XANotesFolder [source]
Moves the folder to the specified container.
- Returns:
The folder object.
- Return type:
New in version 0.2.0.
- property name: str
The name of the folder.
- notes(filter: dict | None = None) XANoteList [source]
Returns a list of notes, as PyXA objects, matching the given filter.
- Parameters:
filter (dict, optional) – Keys and values to filter notes by, defaults to None
- Returns:
A PyXA list object wrapping a list of notes
- Return type:
Changed in version 0.0.3: Now returns an object of
XANoteList
instead of a default list.New in version 0.0.1.
Whether the folder is shared.
- show() XANotesFolder [source]
Shows the folder in the main Notes window.
- Returns:
The folder object.
- Return type:
New in version 0.0.3.
- class PyXA.apps.Notes.XANotesFolderList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
,XAClipboardCodable
A wrapper around a list of Notes folders.
New in version 0.0.3.
Methods:
by_container
(container)by_id
(id)by_name
(name)by_shared
(shared)folders
()Gets a clipboard-codable representation of each folder in the list.
id
()name
()notes
()shared
()- by_container(container: XANotesAccount) XANotesFolder [source]
- by_id(id: str) XANotesFolder [source]
- by_name(name: str) XANotesFolder [source]
- container() XANotesAccountList [source]
- folders() XANotesFolderList [source]
- get_clipboard_representation() list[str] [source]
Gets a clipboard-codable representation of each folder in the list.
When the clipboard content is set to a list of folders, the name of each folder is added to the clipboard.
- Returns:
A list of folder names
- Return type:
list[str]
New in version 0.0.8.
- notes() XANoteList [source]
- class PyXA.apps.Notes.XANotesWindow(properties)[source]
Bases:
XASBWindow
A window of Notes.app.
New in version 0.0.1.
Attributes:
The active document.
- property document: XANotesDocument
The active document.