From d705c9c2f4f1456b30c5afba949cd7a1eba51e43 Mon Sep 17 00:00:00 2001 From: Eric Richter Date: Tue, 24 Oct 2017 19:47:23 -0500 Subject: [PATCH] halibot: add optional working directory override to core --- halibot/halibot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/halibot/halibot.py b/halibot/halibot.py index 910d592..407bf55 100644 --- a/halibot/halibot.py +++ b/halibot/halibot.py @@ -43,6 +43,7 @@ def __init__(self, **kwargs): self.use_config = kwargs.get("use_config", True) self.use_auth = kwargs.get("use_auth", True) + self.workdir = kwargs.get("workdir", ".") self.auth = HalAuth() self.objects = ObjectDict() @@ -89,12 +90,12 @@ def add_instance(self, name, inst): self.log.info("Instantiated object '" + name + "'") def _load_config(self): - with open("config.json","r") as f: + with open(os.path.join(self.workdir, "config.json"), "r") as f: self.config = json.loads(f.read()) halibot.packages.__path__ = self.config.get("package-path", []) def _write_config(self): - with open("config.json", "w") as f: + with open(os.path.join(self.workdir, "config.json"), "w") as f: f.write(json.dumps(self.config, sort_keys=True, indent=4))