Get back into tox's good graces
This commit is contained in:
@@ -20,17 +20,18 @@
|
||||
import config
|
||||
import pkg_resources
|
||||
|
||||
|
||||
class Jargon(object):
|
||||
def __init__(self, rawdata: dict):
|
||||
self._rawdata = rawdata
|
||||
|
||||
# copy the data to lowercase keys, ignore blank keys
|
||||
self._data = {str(k).lower():v for k,v in rawdata.items() if k}
|
||||
self._data = {str(k).lower(): v for k, v in rawdata.items() if k}
|
||||
|
||||
def get(self, term: str) -> str:
|
||||
return self._data.get(term.lower())
|
||||
|
||||
def get_rawdata() -> dict:
|
||||
def get_rawdata(self) -> dict:
|
||||
return self._rawdata
|
||||
|
||||
def apply(self, query):
|
||||
|
||||
@@ -26,11 +26,12 @@ from .resources import DEFAULT_DATA, DEFAULT_HEADER
|
||||
|
||||
JARGON_PATH = os.path.join(config.savePath, 'jargon.yaml')
|
||||
|
||||
|
||||
class JargonLoader(object):
|
||||
def __init__(self, jargon_path: str):
|
||||
self.jargon_path = jargon_path
|
||||
self._jargon_mtime = 0 # type: int
|
||||
self._jargon = None # type: Jargon
|
||||
self._jargon_mtime = 0 # type: int
|
||||
self._jargon = None # type: Jargon
|
||||
|
||||
def get_jargon(self) -> Jargon:
|
||||
if self._is_stale():
|
||||
@@ -58,7 +59,7 @@ class JargonLoader(object):
|
||||
def init_user_jargon(jargon_path):
|
||||
values = yaml.load(DEFAULT_DATA)
|
||||
|
||||
## Disabled for issue/1533; do not overwrite existing user config
|
||||
# Disabled for issue/1533; do not overwrite existing user config
|
||||
# if os.path.exists(jargon_path):
|
||||
# with open(jargon_path) as f:
|
||||
# custom_values = yaml.load(f)
|
||||
@@ -72,6 +73,7 @@ class JargonLoader(object):
|
||||
yaml.dump(values, stream=f, default_flow_style=False)
|
||||
|
||||
_instance = None
|
||||
|
||||
@staticmethod
|
||||
def instance(jargon_path=None):
|
||||
if not JargonLoader._instance:
|
||||
@@ -79,4 +81,5 @@ class JargonLoader(object):
|
||||
JargonLoader._instance = JargonLoader(jargon_path)
|
||||
return JargonLoader._instance
|
||||
|
||||
|
||||
JargonLoader.init_user_jargon(JARGON_PATH)
|
||||
|
||||
Reference in New Issue
Block a user