adjust demo.py and the config template to use my.config

This commit is contained in:
Dima Gerasimov 2020-04-11 22:04:22 +01:00
parent 4d33416696
commit 2bcde388d7
7 changed files with 38 additions and 24 deletions

View file

@ -1,13 +1,15 @@
"""
Hypothes.is highlights and annotations
"""
from . import init
from .common import PathIsh
import mycfg.repos.hypexport as hypexport
import my.config.repos.hypexport as hypexport
from my.config.repos.hypexport import dal
from mycfg import paths
export_path: PathIsh = paths.hypothesis.export_path
from my.config import hypothesis as config
export_path: PathIsh = config.export_path
###
@ -17,7 +19,6 @@ from .common import get_files, cproperty, group_by_key
from .error import Res, sort_res_by
from mycfg.repos.hypexport import dal
# TODO weird. not sure why e.g. from dal import Highlight doesn't work..

View file

@ -13,11 +13,18 @@ A hook to insert user's config directory into Python's search path.
def setup_config():
from pathlib import Path
import sys
import os
import warnings
# TODO use appdir??
cfg_dir = Path('~/.config').expanduser()
mycfg_dir = cfg_dir / 'my'
# not sure if that's necessary, i.e. could rely on PYTHONPATH instead
# on the other hand, by using MY_CONFIG we are guaranteed to load it from the desired path?
mvar = os.environ.get('MY_CONFIG')
if mvar is not None:
mycfg_dir = Path(mvar)
else:
# TODO use appdir??
cfg_dir = Path('~/.config').expanduser()
mycfg_dir = cfg_dir / 'my'
# TODO maybe try importing first and if it's present, don't do anything?