general: migrate modules to use 3.9 features
This commit is contained in:
parent
d3f9a8e8b6
commit
8496d131e7
125 changed files with 889 additions and 739 deletions
|
@ -5,16 +5,15 @@ REQUIRES = [
|
|||
'git+https://github.com/karlicoss/rescuexport',
|
||||
]
|
||||
|
||||
from pathlib import Path
|
||||
from collections.abc import Iterable, Sequence
|
||||
from datetime import timedelta
|
||||
from typing import Sequence, Iterable
|
||||
from pathlib import Path
|
||||
|
||||
from my.core import get_files, make_logger, stat, Stats
|
||||
from my.core import Stats, get_files, make_logger, stat
|
||||
from my.core.cachew import mcachew
|
||||
from my.core.error import Res, split_errors
|
||||
|
||||
from my.config import rescuetime as config
|
||||
|
||||
from my.config import rescuetime as config # isort: skip
|
||||
|
||||
logger = make_logger(__name__)
|
||||
|
||||
|
@ -24,6 +23,7 @@ def inputs() -> Sequence[Path]:
|
|||
|
||||
|
||||
import rescuexport.dal as dal
|
||||
|
||||
DAL = dal.DAL
|
||||
Entry = dal.Entry
|
||||
|
||||
|
@ -43,6 +43,8 @@ def groups(gap: timedelta=timedelta(hours=3)) -> Iterable[Res[Sequence[Entry]]]:
|
|||
|
||||
# todo automatic dataframe interface?
|
||||
from .core.pandas import DataFrameT, as_dataframe
|
||||
|
||||
|
||||
def dataframe() -> DataFrameT:
|
||||
return as_dataframe(entries())
|
||||
|
||||
|
@ -56,16 +58,19 @@ def stats() -> Stats:
|
|||
|
||||
# basically, hack config and populate it with fake data? fake data generated by DAL, but the rest is handled by this?
|
||||
|
||||
from collections.abc import Iterator
|
||||
from contextlib import contextmanager
|
||||
from typing import Iterator
|
||||
|
||||
|
||||
# todo take seed, or what?
|
||||
@contextmanager
|
||||
def fake_data(rows: int=1000) -> Iterator:
|
||||
# todo also disable cachew automatically for such things?
|
||||
from my.core.cfg import tmp_config
|
||||
from my.core.cachew import disabled_cachew
|
||||
from tempfile import TemporaryDirectory
|
||||
import json
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from my.core.cachew import disabled_cachew
|
||||
from my.core.cfg import tmp_config
|
||||
with disabled_cachew(), TemporaryDirectory() as td:
|
||||
tdir = Path(td)
|
||||
f = tdir / 'rescuetime.json'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue