def _patch_browserexport_logs(): # patch browserexport logs if HPI_LOGS is present if "HPI_LOGS" in os.environ: from browserexport.log import setup as setup_browserexport_logger from my.core.logging import mklevel setup_browserexport_logger(mklevel(os.environ["HPI_LOGS"]))
def _data() -> Tuple[List[Snapshot], List[Transaction]]: """ Get data from the budget module (data is handled by that/environment variables) see https://github.com/seanbreckenridge/mint """ debug: bool = False if "HPI_LOGS" in os.environ: if mklevel(os.environ["HPI_LOGS"]) == logging.DEBUG: debug = True return data(debug=debug)
all_history as M_all_history, _actually_listened_to, ) from my.core import get_files, Stats, LazyLogger from my.core.common import mcachew from .utils.common import InputSource # monkey patch logs if "HPI_LOGS" in os.environ: from logzero import setup_logger # type: ignore[import] from my.core.logging import mklevel import mpv_history_daemon.events mpv_history_daemon.events.logger = setup_logger( name="mpv_history_events", level=mklevel(os.environ["HPI_LOGS"])) logger = LazyLogger(__name__, level="warning") Results = Iterator[Media] def stats() -> Stats: from my.core import stat return { **stat(history), } def inputs() -> Sequence[Path]:
import os from pathlib import Path from typing import Iterator, List from my.core import Stats, get_files, LazyLogger from my.core.common import mcachew from my.core.sqlite import sqlite_copy_and_open # patch browserexport logs if HPI_LOGS is present if "HPI_LOGS" in os.environ: from browserexport.log import setup as setup_browserexport_logger from my.core.logging import mklevel setup_browserexport_logger(mklevel(os.environ["HPI_LOGS"])) logger = LazyLogger(__name__, level="warning") from browserexport.merge import read_and_merge, merge_visits, Visit from browserexport.parse import read_visits # all of my backed up databases def backup_inputs() -> List[Path]: return list(get_files(config.export_path)) # return the visits from the live sqlite database, # copying the live database in memory def _live_visits() -> List[Visit]:
class google(user_config): # directory to unzipped takeout data takeout_path: Paths config = make_config(google) logger = LazyLogger(__name__, level="warning") # patch TAKEOUT_LOGS to match HPI_LOGS if "HPI_LOGS" in os.environ: from google_takeout_parser.log import setup as setup_takeout_logger from my.core.logging import mklevel setup_takeout_logger(mklevel(os.environ["HPI_LOGS"])) DISABLE_TAKEOUT_CACHE = "DISABLE_TAKEOUT_CACHE" in os.environ def inputs() -> List[Path]: return list(get_files(config.takeout_path)) EXPECTED = ( "My Activity", "Chrome", "Location History", "Youtube", "YouTube and YouTube Music",
import os from pathlib import Path from typing import Iterator, Sequence, Optional from my.core import get_files, Stats, Res from my.core.logging import mklevel from my.utils.input_source import InputSource from lolexport.merge import Game, merge_game_histories import lolexport.log as llog from logzero import setup_logger # type: ignore[import] # configure logs llog.logger = setup_logger( name="lolexport", level=mklevel(os.environ["HPI_LOGS"] if "HPI_LOGS" in os.environ else "INFO"), ) def inputs() -> Sequence[Path]: return get_files(config.export_path) Results = Iterator[Res[Game]] def history( from_paths: InputSource = inputs, summoner_name: Optional[str] = None ) -> Results: sname = summoner_name or config.username for g in merge_game_histories(list(from_paths()), username=sname):