diff options
Diffstat (limited to 'yarnhelper.py')
-rw-r--r-- | yarnhelper.py | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/yarnhelper.py b/yarnhelper.py index 4ed2c03..5948664 100644 --- a/yarnhelper.py +++ b/yarnhelper.py @@ -34,44 +34,7 @@ class YarnHelper(object): def __init__(self): self._env = dict(os.environ) - self._next_match = 1 self._filename = os.path.join(datadir, variables_filename) - self._variables = None # None means not loaded, otherwise dict - - def set_environment(self, env): - self._env = dict(env) - - def get_next_match(self): - name = 'MATCH_{}'.format(self._next_match) - if name not in self._env: - raise Error('no next match') - self._next_match += 1 - return self._env[name] - - def get_variable(self, name, default=None): - if self._variables is None: - self._variables = self._load_variables() - assert self._variables is not None - return self._variables.get(name, default) - - def _load_variables(self): - if os.path.exists(self._filename): - with open(self._filename, 'r') as f: - data = f.read() - if data: - f.seek(0) - return yaml.safe_load(f) - return {} - - def set_variable(self, name, value): - if self._variables is None: - self._variables = {} - self._variables[name] = value - self._save_variables(self._variables) - - def _save_variables(self, variables): - with open(self._filename, 'w') as f: - yaml.safe_dump(variables, f) def construct_aliased_http_request( self, address, method, url, data=None, headers=None): |