From 3b03591ddaef441a07ee9e5b2cf732e4255001aa Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Tue, 24 Mar 2020 20:02:38 +0000 Subject: [PATCH] prettify instapaper module --- my/instapaper.py | 31 +++---------------------------- my/kython/kompress.py | 2 +- tests/instapaper.py | 6 ++++++ 3 files changed, 10 insertions(+), 29 deletions(-) create mode 100644 tests/instapaper.py diff --git a/my/instapaper.py b/my/instapaper.py index 87dec08..224906a 100644 --- a/my/instapaper.py +++ b/my/instapaper.py @@ -1,38 +1,18 @@ """ Instapaper bookmarks, highlights and annotations """ -from datetime import datetime -import json from pathlib import Path -from typing import NamedTuple, Optional, List, Dict, Iterator, Tuple -from collections import OrderedDict - -import pytz +from typing import NamedTuple, Optional, List, Iterator from .common import group_by_key, PathIsh, get_files -# TODO need to make configurable? -# TODO wonder if could autodetect from promnesia somehow.. -# tbh, seems like venvs would be suited well for that.. +from mycfg import paths import mycfg.repos.instapexport.dal as dal -# TODO FIXME remove that stuff -_export_path: Optional[Path] = None -def configure(*, export_path: Optional[PathIsh]=None) -> None: - if export_path is not None: - global _export_path - _export_path = Path(export_path) - - def _get_files(): - export_path = _export_path - if export_path is None: - # fallback to mycfg - from mycfg import paths - export_path = paths.instapaper.export_path - return get_files(export_path, glob='*.json') + return get_files(paths.instapaper.export_path, glob='*.json') def get_dal() -> dal.DAL: @@ -70,11 +50,6 @@ def get_todos() -> Iterator[HighlightWithBm]: return filter(is_todo, iter_highlights()) -def test_get_todos(): - for t in get_todos(): - print(t) - - def main(): for h in get_todos(): print(h) diff --git a/my/kython/kompress.py b/my/kython/kompress.py index ecbbfa2..3d43f76 100644 --- a/my/kython/kompress.py +++ b/my/kython/kompress.py @@ -44,7 +44,7 @@ class CPath(PosixPath): return kopen(str(self)) -open = kopen # TODO FIXME remove? +open = kopen # TODO remove? # meh diff --git a/tests/instapaper.py b/tests/instapaper.py new file mode 100644 index 0000000..2c492e8 --- /dev/null +++ b/tests/instapaper.py @@ -0,0 +1,6 @@ +from my.instapaper import get_todos + + +def test_get_todos(): + for t in get_todos(): + print(t)