Raise if working_dir is None

Check for this in the init so we can remove the duplication of
raising in further functions.

A ServiceLoader isn't valid without one.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-08-20 15:05:33 +01:00
parent 3bee62e4c5
commit c907f35e74
1 changed files with 4 additions and 6 deletions

View File

@ -152,7 +152,11 @@ def load(config_details):
class ServiceLoader(object):
def __init__(self, working_dir, filename=None, already_seen=None):
if working_dir is None:
raise Exception("No working_dir passed to ServiceLoader()")
self.working_dir = os.path.abspath(working_dir)
if filename:
self.filename = os.path.abspath(filename)
else:
@ -176,9 +180,6 @@ class ServiceLoader(object):
extends_options = self.validate_extends_options(service_dict['name'], service_dict['extends'])
if self.working_dir is None:
raise Exception("No working_dir passed to ServiceLoader()")
if 'file' in extends_options:
extends_from_filename = extends_options['file']
other_config_path = expand_path(self.working_dir, extends_from_filename)
@ -320,9 +321,6 @@ def get_env_files(options, working_dir=None):
if 'env_file' not in options:
return {}
if working_dir is None:
raise Exception("No working_dir passed to get_env_files()")
env_files = options.get('env_file', [])
if not isinstance(env_files, list):
env_files = [env_files]