hyperdiary package

Submodules

hyperdiary.check module

hyperdiary.check.check(diary: hyperdiary.diary.Diary) → None[source]

hyperdiary.diary module

exception hyperdiary.diary.BadEntryException[source]

Bases: Exception

class hyperdiary.diary.DateRange(start: datetime.date, end: datetime.date)[source]

Bases: object

static from_json(obj: Mapping[str, str]) → hyperdiary.diary.DateRange[source]
class hyperdiary.diary.DayEntry(dt: datetime.date, lines: List[str])[source]

Bases: object

Diary entry for a specific date, contains multiple lines of text.

iter_lines() → Iterable[Tuple[datetime.date, str]][source]
class hyperdiary.diary.Diary(hyperdiary_json: Mapping[KT, VT_co])[source]

Bases: object

static discover(subpath: Union[pathlib.Path, str]) → hyperdiary.diary.Diary[source]
static discover_and_load(path: Union[pathlib.Path, str] = '.') → hyperdiary.diary.Diary[source]
iter_entries_by_year_and_month() → Iterable[Tuple[int, Iterable[Tuple[int, Iterable[hyperdiary.diary.DayEntry]]]]][source]
iter_lines() → Iterable[Tuple[datetime.date, str]][source]
load_entries() → None[source]
nested_dicts_by_year_and_month() → Mapping[int, Mapping[int, Mapping[datetime.date, hyperdiary.diary.DayEntry]]][source]
class hyperdiary.diary.Token(type: hyperdiary.diary.TokenType, text: str, ref: str = None)[source]

Bases: object

class hyperdiary.diary.TokenType[source]

Bases: enum.Enum

An enumeration.

Id = 3
Tag = 2
Text = 1
hyperdiary.diary.find_ids(line: str) → Iterable[hyperdiary.diary.Token][source]
hyperdiary.diary.find_tags(line: str) → Iterable[hyperdiary.diary.Token][source]
>>> line = "+tag1 +tag2 some content goes here +tag3"
>>> res = [t.text for t in find_tags(line)]
>>> res == ["tag1", "tag2", "tag3"]
True
hyperdiary.diary.find_token_of_type(line: str, token_type: hyperdiary.diary.TokenType) → Iterable[hyperdiary.diary.Token][source]
hyperdiary.diary.tokenize(line: str) → Iterable[hyperdiary.diary.Token][source]

hyperdiary.html module

hyperdiary.html.append_li_a(ul: hyperdiary.htmltags.HTMLElement, text: str, href: str) → None[source]
hyperdiary.html.day_to_html(current: datetime.date, entry: Iterable[str], localization: hyperdiary.localization.Localization, link_to_id_fn: Callable[[Optional[str]], str] = None) → hyperdiary.htmltags.HTMLElement[source]
hyperdiary.html.diary_to_html(diary_instance: hyperdiary.diary.Diary, fname: str) → None[source]
hyperdiary.html.diary_to_html_folder(diary_instance: hyperdiary.diary.Diary, folder: str) → None[source]
hyperdiary.html.path_for_date(dt: datetime.date) → hyperdiary.simplepath.AbsolutePath[source]
hyperdiary.html.rel_path(spath: Union[datetime.date, str, int]) → hyperdiary.simplepath.RelativePath[source]
hyperdiary.html.wrap_html_page(content: Union[HTMLElement, str], title: str = None, level: int = 0) → hyperdiary.htmltags.html[source]
hyperdiary.html.wrap_page(body_content: Union[HTMLElement, str], page_title: str = None, encoding: str = 'utf-8', css_references: Iterable[str] = [], inline_css: str = None) → hyperdiary.htmltags.html[source]

hyperdiary.htmltags module

class hyperdiary.htmltags.HTMLElement(*content, **attributes)[source]

Bases: object

append(*items) → hyperdiary.htmltags.HTMLElement[source]
lazy_render(indent: str = '', add_indent: str = '') → Iterable[str][source]
lazy_render_attributes() → Iterable[str][source]
render_compact = False
subelement(item: hyperdiary.htmltags.HTMLElement) → hyperdiary.htmltags.HTMLElement[source]
tag = 'div'
write(fname: str) → None[source]
class hyperdiary.htmltags.a(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'a'
class hyperdiary.htmltags.article(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'article'
class hyperdiary.htmltags.body(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'body'
class hyperdiary.htmltags.button(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'button'
class hyperdiary.htmltags.div(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'div'
class hyperdiary.htmltags.footer(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'footer'
class hyperdiary.htmltags.form(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'form'
class hyperdiary.htmltags.h1(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'h1'
class hyperdiary.htmltags.h2(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'h2'
class hyperdiary.htmltags.h3(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'h3'
class hyperdiary.htmltags.h4(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'h4'
class hyperdiary.htmltags.head(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'head'
class hyperdiary.htmltags.header(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'header'
class hyperdiary.htmltags.hr(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'hr'
class hyperdiary.htmltags.html(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'html'
class hyperdiary.htmltags.img(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'img'
class hyperdiary.htmltags.li(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'li'

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'link'
class hyperdiary.htmltags.meta(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'meta'
class hyperdiary.htmltags.nav(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'nav'
class hyperdiary.htmltags.ol(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'ol'
class hyperdiary.htmltags.p(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'p'
class hyperdiary.htmltags.small(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'small'
class hyperdiary.htmltags.span(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'span'
class hyperdiary.htmltags.style(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'style'
class hyperdiary.htmltags.table(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'table'
class hyperdiary.htmltags.tbody(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'tbody'
class hyperdiary.htmltags.td(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'td'
class hyperdiary.htmltags.th(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'th'
class hyperdiary.htmltags.thead(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'thead'
class hyperdiary.htmltags.title(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = True
tag = 'title'
class hyperdiary.htmltags.tr(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'tr'
class hyperdiary.htmltags.ul(*content, **attributes)[source]

Bases: hyperdiary.htmltags.HTMLElement

render_compact = False
tag = 'ul'

hyperdiary.hugo module

hyperdiary.hugo.diary_to_hugo(diary_instance: hyperdiary.diary.Diary, folder: Union[pathlib.Path, str]) → None[source]
hyperdiary.hugo.nice_date(dt: datetime.date) → str[source]

hyperdiary.localization module

class hyperdiary.localization.Localization(months: List[str] = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], days_short: List[str] = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], date_fmt: str = '%Y-%m-%d')[source]

Bases: object

format_date(dt: datetime.date) → str[source]

Format to localized string. >>> l = Localization() >>> l.format_date(date(2019, 11, 3)) ‘2019-11-03’ >>> l = Localization(date_fmt=’%d.%m.%Y’) >>> l.format_date(date(2019, 11, 3)) ‘03.11.2019’

get_day_short(i: int) → str[source]

Get the localized name of day i (zero-based index starting Monday). >>> l = Localization() >>> l.get_day_short(0) ‘Mon’ >>> l.get_day_short(6) ‘Sun’ >>> l.get_day_short(7) Traceback (most recent call last): … AssertionError >>> Localization(days_short=[‘Just Mon’]) Traceback (most recent call last): … AssertionError >>> l2 = Localization(days_short=list(‘1234567’)) >>> l2.get_day_short(3) ‘4’ >>> l2.get_day_short(6) ‘7’

get_month(i: int) → str[source]

Get the localized name of month i (zero-based index). >>> l = Localization() >>> l.get_month(0) ‘January’ >>> l.get_month(11) ‘December’ >>> l.get_month(12) Traceback (most recent call last): … AssertionError >>> Localization(months=[‘Just January’]) Traceback (most recent call last): … AssertionError >>> l2 = Localization(months=list(‘123456789ond’)) >>> l2.get_month(3) ‘4’ >>> l2.get_month(10) ‘n’

hyperdiary.simplepath module

class hyperdiary.simplepath.AbsolutePath(path: str)[source]

Bases: object

exception hyperdiary.simplepath.InvalidPathError[source]

Bases: Exception

exception hyperdiary.simplepath.NotARelativePathError[source]

Bases: hyperdiary.simplepath.InvalidPathError

exception hyperdiary.simplepath.NotAnAbsolutePathError[source]

Bases: hyperdiary.simplepath.InvalidPathError

class hyperdiary.simplepath.RelativePath(path: str)[source]

Bases: object

hyperdiary.stats module

hyperdiary.stats.stats(diary: hyperdiary.diary.Diary) → Dict[str, int][source]

hyperdiary.tiddlywiki module

class hyperdiary.tiddlywiki.Tiddler(fname: Union[pathlib.Path, str], **fields)[source]

Bases: object

static from_entry(dt: datetime.date, entry: Iterable[str], localization: hyperdiary.localization.Localization) → hyperdiary.tiddlywiki.Tiddler[source]
text
title
to_div() → str[source]
to_tid() → str[source]
hyperdiary.tiddlywiki.diary_to_tiddlers(diary_instance: hyperdiary.diary.Diary) → Iterator[hyperdiary.tiddlywiki.Tiddler][source]
hyperdiary.tiddlywiki.diary_to_tiddlers_export(diary_instance: hyperdiary.diary.Diary, tiddler_dir: Union[pathlib.Path, str]) → None[source]
hyperdiary.tiddlywiki.diary_to_tiddlywiki_export(diary_instance: hyperdiary.diary.Diary, file: Union[pathlib.Path, str], tiddlywiki_base_file: Union[pathlib.Path, str]) → None[source]
hyperdiary.tiddlywiki.make_tiddler_filename(o: Union[str, datetime.date]) → str[source]
>>> make_tiddler_filename(" Frühstück Ähre Grüße Föhn")
'fruehstueck-aehre-gruesse-foehn.tid'
>>> make_tiddler_filename("a.v-_'üöß' tiddler")
'av-_ueoess-tiddler.tid'
>>> make_tiddler_filename(date(2019, 2, 3))
'2019-02-03.tid'

hyperdiary.view module

hyperdiary.view.view(diary: hyperdiary.diary.Diary, dt: datetime.date) → None[source]

Module contents

hyperdiary.main() → None[source]
hyperdiary.parse_date(sdate: str) → datetime.date[source]