greatday.repo module

Contains the Repo class.

class FileRepo(path)[source]

Bases: potoroo._repo.Repo[str, greatday.todo.GreatTodo]

Repo that stores Todos on disk.

Parameters

path (Union[str, Path]) –

add(todo, /, *, key=None)[source]

Write a new Todo to disk.

Returns a unique identifier that has been associated with this Todo.

Parameters
  • todo (GreatTodo) –

  • key (Optional[str]) –

Return type

Union[Ok[str, ErisError], Err[str, ErisError]]

all()[source]

Retreive all Todos stored on disk.

get(key)[source]

Retrieve a Todo from disk.

Parameters

key (str) –

Return type

ErisResult[GreatTodo | None]

remove(key)[source]

Remove a Todo from disk.

Parameters

key (str) –

Return type

ErisResult[GreatTodo | None]

class SQLRepo(url, *, engine_factory=<functools._lru_cache_wrapper object>, verbose=0)[source]

Bases: potoroo._repo.TaggedRepo[str, greatday.todo.GreatTodo, greatday.tag.GreatTag]

Repo that stores Todos in sqlite database.

Parameters
add(todo, /, *, key=None)[source]

Adds a new Todo to the DB.

Returns a unique identifier that has been associated with this Todo.

Parameters
  • todo (GreatTodo) –

  • key (Optional[str]) –

Return type

Union[Ok[str, ErisError], Err[str, ErisError]]

all()[source]

Returns all Todos contained in the underlying SQL database.

get(key)[source]

Retrieve a Todo from the DB.

Parameters

key (str) –

Return type

ErisResult[GreatTodo | None]

get_by_tag(tag)[source]

Get Todo(s) from DB by using a tag.

remove(key)[source]

Remove a Todo from the DB.

Parameters

key (str) –

Return type

ErisResult[GreatTodo | None]

remove_by_tag(tag)[source]

Removes Todo(s) from DB by using a tag.

class SQLTag(session, tag)[source]

Bases: object

Wrapper around Tag objects that helps build SQL statements.

Parameters
  • session (Session) –

  • tag (Tag) –

date_range_parser(stmt)[source]

Parser for create/done dates (e.g. ‘^2000-01-01’ or ‘$5d:0d’).

Parameters

stmt (SelectOfScalar) –

Return type

SelectOfScalar

desc_parser(stmt)[source]

Parser for todo description (e.g. ‘“foo”’ or ‘!”bar”’)

Parameters

stmt (SelectOfScalar) –

Return type

SelectOfScalar

done_parser(stmt)[source]

Parser for done status (i.e. ‘x’ or ‘o’).

Parameters

stmt (SelectOfScalar) –

Return type

SelectOfScalar

metatag_parser(stmt)[source]

Parser for metatags (e.g. ‘due<=0d’).

Parameters

stmt (SelectOfScalar) –

Return type

SelectOfScalar

prefix_tag_parser(stmt)[source]

Parser for prefix tags (e.g. @home’ or ‘+greatday’).

Parameters

stmt (SelectOfScalar) –

Return type

SelectOfScalar

priority_range_parser(stmt)[source]

Parser for priority range (e.g. ‘(a-c)’).

Parameters

stmt (SelectOfScalar) –

Return type

SelectOfScalar

session
tag
to_stmt()[source]

Constructs a SQL statement from the provided Tag object.

Return type

SelectOfScalar