pyorg.interface module

class pyorg.interface.Org(emacs=None, orgdir=None)[source]

Bases: object

Interface to org mode.

emacs
Type:pyorg.emacs.Emacs
orgdir

Directory org files are read from.

Type:OrgDirectory
agenda(key='t', raw=False)[source]

TODO Read agenda information.

Parameters:key (str) – TODO
Returns:
Return type:list[dict]
open_org_file(path, focus=False)[source]

Open an org file in the org directory for editing in Emacs.

Parameters:
  • path (str or pathlib.Path) – File path relative to org directory.
  • focus (bool) – Switch window/input focus to opened buffer.
read_org_file(path, assign_ids=True)[source]

Read and parse an org file.

Parameters:
Returns:

Return type:

pyorg.ast.OrgNode

Raises:

FileNotFoundError

read_org_file_direct(path, raw=False)[source]

Read and parse an org file directly from Emacs.

Always reads the current file and does not use cached data, or perform any additional processing other than parsing.

Parameters:
  • path (str or pathlib.Path) – File path relative to org directory.
  • raw (bool) – Don’t parse and just return raw JSON exported from Emacs.
Returns:

Return type:

pyorg.ast.OrgNode or dict

Raises:

FileNotFoundError

class pyorg.interface.OrgDirectory(path)[source]

Bases: object

The directory where the user’s org files are kept.

path : pathlib.Path
Absolute path to org directory.
get_abs_path(path)[source]

Get absolute path from path relative to org directory.

Path will be normalized with “..” components removed.

Returns:
Return type:pathlib.Path
Raises:ValueError – If the path is not relative or is outside of the org directory (can happen if it contains “..” components).
list_files(path=None, recursive=False, hidden=False)[source]

List org files within the org directory.

Paths are relative to the org directory.

Parameters:
  • path (str or pathlib.Path) – Optional subdirectory to search through.
  • recursive (bool) – Recurse through subdirectories.
  • hidden (bool) – Include hidden files.
Returns:

Return type:

Iterator over pathlib.Path instances.