* reduce ci matrix
* python runscript without bash
(cherry picked from commit 9b148a6679722db5eb7ffabd3a27a8579f296319)
* change link dest function to handle '\?\' links
* add path normalization for windows support
* Revert "add path normalization for windows support"
This reverts commit 2ab0fc1b3c
.
* link variable extraction without normpath
* type annotation
* blacken
* missing black files
* variable renames from '2775765a' outside link function
* from '2775765a' use method for default flags
* fix defaults from method
* variable renames from '2775765a' in link function and method renames
* refactor if clauses into blocks
* maybe fix if refactor
* remove unreachable code
* remove silly disambiguation semantics
* remove silly disambiguation semantics 2
* incremental else swap
* bring source existence check to front
* bring source existence check to front and remove old back check
* refactor almost final case
* check symlink broken cases up front
* add return missing
* flip block order to make things easier to understand
30 lines
761 B
Python
30 lines
761 B
Python
import yaml
|
|
import json
|
|
import os.path
|
|
from .util import string
|
|
|
|
|
|
class ConfigReader(object):
|
|
def __init__(self, config_file_path):
|
|
self._config = self._read(config_file_path)
|
|
|
|
def _read(self, config_file_path):
|
|
try:
|
|
_, ext = os.path.splitext(config_file_path)
|
|
with open(config_file_path) as fin:
|
|
if ext == ".json":
|
|
data = json.load(fin)
|
|
else:
|
|
data = yaml.safe_load(fin)
|
|
return data
|
|
except Exception as e:
|
|
msg = string.indent_lines(str(e))
|
|
raise ReadingError("Could not read config file:\n%s" % msg)
|
|
|
|
def get_config(self):
|
|
return self._config
|
|
|
|
|
|
class ReadingError(Exception):
|
|
pass
|