From 73e57b52d19d02baa563f936e69052170515bf6a Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Tue, 31 May 2022 20:37:16 +0100 Subject: [PATCH] general: cleanup -- remove main and executable bit where it's not necessary --- my/bluemaestro.py | 0 my/body/blood.py | 8 -------- my/emfit/__init__.py | 3 +-- my/emfit/plot.py | 0 my/foursquare.py | 0 my/jawbone/__init__.py | 1 - my/lastfm.py | 0 my/media/imdb.py | 8 -------- my/pdfs.py | 0 my/polar.py | 24 ++++++++---------------- my/reddit/rexport.py | 9 --------- my/rtm.py | 4 ---- my/youtube/takeout.py | 0 13 files changed, 9 insertions(+), 48 deletions(-) mode change 100755 => 100644 my/bluemaestro.py mode change 100755 => 100644 my/body/blood.py mode change 100755 => 100644 my/emfit/__init__.py mode change 100755 => 100644 my/emfit/plot.py mode change 100755 => 100644 my/foursquare.py mode change 100755 => 100644 my/jawbone/__init__.py mode change 100755 => 100644 my/lastfm.py mode change 100755 => 100644 my/pdfs.py mode change 100755 => 100644 my/polar.py mode change 100755 => 100644 my/reddit/rexport.py mode change 100755 => 100644 my/rtm.py mode change 100755 => 100644 my/youtube/takeout.py diff --git a/my/bluemaestro.py b/my/bluemaestro.py old mode 100755 new mode 100644 diff --git a/my/body/blood.py b/my/body/blood.py old mode 100755 new mode 100644 index 51a5114..c1d66e2 --- a/my/body/blood.py +++ b/my/body/blood.py @@ -130,11 +130,3 @@ def stats(): def test(): print(dataframe()) assert len(dataframe()) > 10 - - -def main(): - print(data()) - - -if __name__ == '__main__': - main() diff --git a/my/emfit/__init__.py b/my/emfit/__init__.py old mode 100755 new mode 100644 index 3ad2b15..997ba6c --- a/my/emfit/__init__.py +++ b/my/emfit/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 """ [[https://shop-eu.emfit.com/products/emfit-qs][Emfit QS]] sleep tracker @@ -29,7 +28,7 @@ def dir_hash(path: Path): # TODO take __file__ into account somehow? -@mcachew(cache_path=cache_dir() / 'emfit.cache', hashf=lambda: dir_hash(config.export_path), logger=dal.log) +@mcachew(cache_path=cache_dir() / 'emfit.cache', hashf=lambda: dir_hash(config.export_path)) def datas() -> Iterable[Res[Emfit]]: import dataclasses diff --git a/my/emfit/plot.py b/my/emfit/plot.py old mode 100755 new mode 100644 diff --git a/my/foursquare.py b/my/foursquare.py old mode 100755 new mode 100644 diff --git a/my/jawbone/__init__.py b/my/jawbone/__init__.py old mode 100755 new mode 100644 index 28ef937..50932bf --- a/my/jawbone/__init__.py +++ b/my/jawbone/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 from typing import Dict, Any, List, Iterable import json from functools import lru_cache diff --git a/my/lastfm.py b/my/lastfm.py old mode 100755 new mode 100644 diff --git a/my/media/imdb.py b/my/media/imdb.py index 63531fe..b7ecbde 100644 --- a/my/media/imdb.py +++ b/my/media/imdb.py @@ -38,11 +38,3 @@ def get_movies() -> List[Movie]: def test(): assert len(get_movies()) > 10 - - -def main(): - for movie in get_movies(): - print(movie) - -if __name__ == '__main__': - main() diff --git a/my/pdfs.py b/my/pdfs.py old mode 100755 new mode 100644 diff --git a/my/polar.py b/my/polar.py old mode 100755 new mode 100644 index 2218c29..0f2ee82 --- a/my/polar.py +++ b/my/polar.py @@ -7,6 +7,7 @@ from typing import cast, TYPE_CHECKING import my.config +# todo use something similar to tz.via_location for config fallback if not TYPE_CHECKING: user_config = getattr(my.config, 'polar', None) else: @@ -40,9 +41,9 @@ from datetime import datetime from typing import List, Dict, Iterable, NamedTuple, Sequence, Optional import json -from .core import LazyLogger, Json +from .core import LazyLogger, Json, Res from .core.common import isoparse -from .error import Res, echain, sort_res_by +from .core.error import echain, sort_res_by from .core.konsume import wrap, Zoomable, Wdict @@ -108,7 +109,7 @@ class Loader: # TODO something nicer? notes = meta['notes'].zoom() else: - notes = [] # TODO FIXME dict? + notes = [] comments = list(meta['comments'].zoom().values()) if 'comments' in meta else [] meta['questions'].zoom() meta['flashcards'].zoom() @@ -191,7 +192,7 @@ class Loader: ) h.consume() - # TODO FIXME when I add defensive error policy, support it + # TODO when I add defensive error policy, support it # if len(cmap) > 0: # raise RuntimeError(f'Unconsumed comments: {cmap}') # TODO sort by date? @@ -209,10 +210,10 @@ class Loader: # TODO konsume here as well? di = j['docInfo'] added = di['added'] - filename = di['filename'] # TODO here + filename = di['filename'] title = di.get('title', None) tags_dict = di['tags'] - pm = j['pageMetas'] # TODO FIXME handle this too + pm = j['pageMetas'] # todo handle this too? # todo defensive? tags = tuple(t['label'] for t in tags_dict.values()) @@ -247,14 +248,5 @@ def get_entries() -> List[Result]: return list(sort_res_by(iter_entries(), key=lambda e: e.created)) -def main(): - for e in iter_entries(): - if isinstance(e, Exception): - logger.exception(e) - else: - logger.info('processed %s', e.uid) - for i in e.items: - logger.info(i) - - +## deprecated Error = Exception # for backwards compat with Orger; can remove later diff --git a/my/reddit/rexport.py b/my/reddit/rexport.py old mode 100755 new mode 100644 index e7373cd..0924e55 --- a/my/reddit/rexport.py +++ b/my/reddit/rexport.py @@ -238,12 +238,3 @@ def stats() -> Stats: **stat(upvoted ), } - -def main() -> None: - for e in events(parallel=False): - print(e) - - -if __name__ == '__main__': - main() - diff --git a/my/rtm.py b/my/rtm.py old mode 100755 new mode 100644 index 2731049..b4fc7a9 --- a/my/rtm.py +++ b/my/rtm.py @@ -114,7 +114,3 @@ def active_tasks() -> Iterator[MyTodo]: if not t.is_completed(): yield t - -def print_all_todos(): - for t in all_tasks(): - print(t) diff --git a/my/youtube/takeout.py b/my/youtube/takeout.py old mode 100755 new mode 100644