prettify instapaper module
This commit is contained in:
parent
c84754250f
commit
3b03591dda
3 changed files with 10 additions and 29 deletions
|
@ -1,38 +1,18 @@
|
||||||
"""
|
"""
|
||||||
Instapaper bookmarks, highlights and annotations
|
Instapaper bookmarks, highlights and annotations
|
||||||
"""
|
"""
|
||||||
from datetime import datetime
|
|
||||||
import json
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import NamedTuple, Optional, List, Dict, Iterator, Tuple
|
from typing import NamedTuple, Optional, List, Iterator
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
import pytz
|
|
||||||
|
|
||||||
from .common import group_by_key, PathIsh, get_files
|
from .common import group_by_key, PathIsh, get_files
|
||||||
|
|
||||||
|
|
||||||
# TODO need to make configurable?
|
from mycfg import paths
|
||||||
# TODO wonder if could autodetect from promnesia somehow..
|
|
||||||
# tbh, seems like venvs would be suited well for that..
|
|
||||||
import mycfg.repos.instapexport.dal as dal
|
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():
|
def _get_files():
|
||||||
export_path = _export_path
|
return get_files(paths.instapaper.export_path, glob='*.json')
|
||||||
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')
|
|
||||||
|
|
||||||
|
|
||||||
def get_dal() -> dal.DAL:
|
def get_dal() -> dal.DAL:
|
||||||
|
@ -70,11 +50,6 @@ def get_todos() -> Iterator[HighlightWithBm]:
|
||||||
return filter(is_todo, iter_highlights())
|
return filter(is_todo, iter_highlights())
|
||||||
|
|
||||||
|
|
||||||
def test_get_todos():
|
|
||||||
for t in get_todos():
|
|
||||||
print(t)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for h in get_todos():
|
for h in get_todos():
|
||||||
print(h)
|
print(h)
|
||||||
|
|
|
@ -44,7 +44,7 @@ class CPath(PosixPath):
|
||||||
return kopen(str(self))
|
return kopen(str(self))
|
||||||
|
|
||||||
|
|
||||||
open = kopen # TODO FIXME remove?
|
open = kopen # TODO remove?
|
||||||
|
|
||||||
|
|
||||||
# meh
|
# meh
|
||||||
|
|
6
tests/instapaper.py
Normal file
6
tests/instapaper.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from my.instapaper import get_todos
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_todos():
|
||||||
|
for t in get_todos():
|
||||||
|
print(t)
|
Loading…
Add table
Reference in a new issue