A tiny tool using script as schema to schedule one day and remind you to do something during a day.
Project description
Schemdule
Schemdule is a tiny tool using script as schema to schedule one day and remind you to do something during a day.
- Platform
- Python
Install
Use pip:
pip install schemdule
Or use pipx:
# Install pipx
pip install --user pipx
pipx ensurepath
# Install Schemdule
pipx install schemdule
# Install extension
pipx inject schemdule schemdule-extensions-{extension name}
# Upgrade
pipx upgrade schemdule --include-injected
Usage
Write a Schema
An example schema.
# Schema
at("6:30", "Get up")
cycle("8:00", "12:00", "00:30:00", "00:10:00", "Working")
# Import other schema by `load` function
# load("other_schema.py")
prompter.useTkinterMessageBox()
# ext("simplegui") # use simplegui extension (package schemdule-extensions-simplegui)
# use multiple prompter:
# prompter.useBroadcaster().useConsole().useMessageBox(True)
The built timetable is like the following one.
๐ก 06:30:00 - ๐ 08:00:00 ๐ Get up
๐ 08:00:00 - ๐ฃ 08:30:00 ๐ผ Working (cycle 1 starting)
๐ฃ 08:30:00 - ๐ฃ 08:40:00 โ Working (cycle 1 resting starting)
๐ฃ 08:40:00 - ๐ 09:10:00 ๐ผ Working (cycle 2 starting)
๐ 09:10:00 - ๐ 09:20:00 โ Working (cycle 2 resting starting)
๐ 09:20:00 - ๐ค 09:50:00 ๐ผ Working (cycle 3 starting)
๐ค 09:50:00 - ๐ 10:00:00 โ Working (cycle 3 resting starting)
๐ 10:00:00 - ๐ฅ 10:30:00 ๐ผ Working (cycle 4 starting)
๐ฅ 10:30:00 - ๐ฅ 10:40:00 โ Working (cycle 4 resting starting)
๐ฅ 10:40:00 - ๐ 11:10:00 ๐ผ Working (cycle 5 starting)
๐ 11:10:00 - ๐ 11:20:00 โ Working (cycle 5 resting starting)
๐ 11:20:00 - ๐ฆ 11:50:00 ๐ผ Working (cycle 6 starting)
๐ฆ 11:50:00 - ๐ฆ 11:50:00 โ Working (cycle 6 resting starting)
Run
# load and run from the schema
schemdule run schema.py
# or use python
# python -m schemdule run schema.py
# preview the built timetable
schemdule run schema.py --preview
# try the builtin demo (just for testing)
schemdule demo
Schema Specification
Schema is a pure python script, so you can use any python statement in it.
Schemdule provide at
, cycle
, load
and ext
functions for registering events, and a PrompterBuilder
variable named prompter
to config prompter.
These functions and variable can be accessed and modified in the variable
env
, a dict for these items provided by Schemdule. You can change theenv
variable to change the execute environment forload
function.
# raw_time can be {hh:mm} or {hh:mm:ss} or a datetime.time object
def at(raw_time: Union[str, time], message: str = "", payload: Any = None) -> None:
# register an event at time with message
# if payload is a PayloadBuilder, Schemdule will build the final payload automaticly,
# same as cycle function's payload parameters
...
def cycle(raw_start: Union[str, time], raw_end: Union[str, time], raw_work_duration: Union[str, time, timedelta], raw_rest_duration: Union[str, time, timedelta], message: str = "", work_payload: Any = None, rest_payload: Any = None) -> None:
# register a series of events in cycle during start to end
# the duration of one cycle = work_duration + rest_duration
# For each cycle, register 2 event: cycle starting, cycle resting
...
def loadRaw(source: str) -> None:
# load from a schema source code
...
def load(file: str, encoding: str = "utf8") -> None:
# load from a schema source code file
...
def ext(name: Optional[str] = None) -> None:
# use an extension or use all installed extensions (if name is None)
# provided by packages `schemdule-extensions-{extension name}`
...
def payloads() -> PayloadBuilder:
# create a payload builder
...
# the class PayloadBuilder
class PayloadBuilder:
def use(self, payload: Any) -> "PayloadBuilder": ...
# the class of the variable `prompter`
class PrompterBuilder:
def use(self, prompter: Prompter) -> "PrompterBuilder": ...
def useBroadcaster(self, final: bool = False) -> "PrompterBuilder": ...
def useSwitcher(self, final: bool = False) -> "PrompterBuilder": ...
def useConsole(self, final: bool = False) -> "PrompterBuilder": ...
def useCallable(self, final: bool = False) -> "PrompterBuilder": ...
def useTkinterMessageBox(self, final: bool = False) -> "PrompterBuilder": ...
def clear(self) -> "PrompterBuilder": ...
# the default value of the variable `prompter`
def default_prompter_builder() -> PrompterBuilder:
prompter = PrompterBuilder()
prompter.useSwitcher().useConsole().useCallable(True).useTkinterMessageBox()
return prompter
Here are the type annotions for schema.
# Type annotions
from typing import Callable, Union, Any, Dict, Optional
from datetime import time, timedelta
from schemdule.prompters.builders import PrompterBuilder, PayloadBuilder
from schemdule.prompters import Prompter, PrompterHub
at: Callable[[Union[str, time], str, Any], None]
cycle: Callable[[Union[str, time], Union[str, time], Union[str, time, timedelta], Union[str, time, timedelta], str, Any, Any], None]
loadRaw: Callable[[str], None]
load: Callable[[str], None]
ext: Callable[[Optional[str]], None]
payloads: Callable[[None], PayloadBuilder]
prompter: PrompterBuilder
env: Dict[str, Any]
Extensions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for schemdule-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40085e81689668ca16cc23ac29256ad57a5d27f6c1941de4016b82e1b3a727bf |
|
MD5 | b0ed2c9889e0dda08171e8ca9c50b297 |
|
BLAKE2b-256 | 5d426fb1b88e03778e9c76bb0bfd4e02b364668e767e50acbabd642cf054b4ab |