Rename dir to path

This commit is contained in:
Dima Gerasimov 2019-11-07 21:08:01 +00:00
parent 16b8878717
commit 0b0a8c2afc
2 changed files with 30 additions and 13 deletions

View file

@ -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

View file

@ -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