my.pdfs: cleanup/refactor

- modernize:
  - add REQUIRES spec for pdfannots library
  - config dataclass/config stub
  - stats function
  - absolute my.core imports in anticipation of splitting core
- use 'paths' instead of 'roots' (better reflects the semantics), use get_files
  backward compatible via config migration
- properly run tests/mypy
This commit is contained in:
Dima Gerasimov 2021-03-30 22:00:21 +01:00 committed by karlicoss
parent e7604c188e
commit ad177a1ccd
6 changed files with 177 additions and 108 deletions

View file

@ -164,7 +164,9 @@ def get_files(
warnings.warn(f"{caller()}: treating {gs} as glob path. Explicit glob={glob} argument is ignored!")
paths.extend(map(Path, do_glob(gs)))
elif src.is_dir():
gp: Iterable[Path] = src.glob(glob) # todo not sure if should be recursive?
# todo not sure if should be recursive?
# note: glob='**/*.ext' works without any changes.. so perhaps it's ok as it is
gp: Iterable[Path] = src.glob(glob)
paths.extend(gp)
else:
if not src.is_file():

View file

@ -29,6 +29,8 @@ def is_data_provider(fun) -> bool:
1. returns iterable or something like that
2. takes no arguments? (otherwise not callable by stats anyway?)
"""
# todo maybe for 2 allow default arguments? not sure
# one example which could benefit is my.pdfs
if fun is None:
return False
# todo. uh.. very similar to what cachew is trying to do?