From 0b0a8c2afcd8972d086f16710af76f68cacaa5ad Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Thu, 7 Nov 2019 21:08:01 +0000 Subject: [PATCH] Rename dir to path --- my/instapaper.py | 30 +++++++++++++++++++----------- my/tweets.py | 13 +++++++++++-- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/my/instapaper.py b/my/instapaper.py index d36b025..8747717 100644 --- a/my/instapaper.py +++ b/my/instapaper.py @@ -1,3 +1,12 @@ +""" +Uses instapaper API data export JSON file. + +Set via +- ~configure~ method +- or in ~my_configuration.instpaper.export_path~ + +TODO upload my exporter script to github.. +""" from datetime import datetime import json from pathlib import Path @@ -9,22 +18,21 @@ import pytz from .common import group_by_key, PathIsh -_export_dir: Optional[Path] = None - - -def configure(*, export_dir: Optional[PathIsh]=None) -> None: - if export_dir is not None: - global _export_dir - _export_dir = Path(export_dir) +_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_dir = _export_dir - if export_dir is None: + # TODO use helper method from common to get json[s]? + export_path = _export_path + if export_path is None: # fallback to my_configuration from . import paths - export_dir = paths.instapexport.export_dir - return list(sorted(Path(export_dir).glob('*.json'))) + export_path = paths.instapaper.export_path + return list(sorted(Path(export_path).glob('*.json'))) Bid = str diff --git a/my/tweets.py b/my/tweets.py index dd71fde..029dd6b 100755 --- a/my/tweets.py +++ b/my/tweets.py @@ -1,4 +1,14 @@ -#!/usr/bin/env python3 +""" +Uses official twitter archive export + +See https://help.twitter.com/en/managing-your-account/how-to-download-your-twitter-archive + +Expects path to be set +- via ~configure~ (before calling anything else) +- or in ~my_configuration.twitter.export_path~ +""" + + from datetime import date, datetime from typing import Union, List, Dict, Set, Optional, Iterator, Any from pathlib import Path @@ -11,7 +21,6 @@ from .common import PathIsh _export_path: Optional[Path] = None - def configure(*, export_path: Optional[PathIsh]=None) -> None: if export_path is not None: global _export_path