rascunho

commit e318017c5e538644becbd4eb7fe74804e1024b4e

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

Configuration, search for common paths or raise an exception

 rascunho/config.py | 12 +++++++++++-


diff --git a/rascunho/config.py b/rascunho/config.py
index 30c507fa0d04934468781a4121749e2a81f8793f..30b3657d767d703e11020d44b6ad9880c27bbc19 100644
--- a/rascunho/config.py
+++ b/rascunho/config.py
@@ -1,7 +1,17 @@
 from configparser import ConfigParser
 
 config = ConfigParser()
-config.read_file(open('config.ini'))
+paths = ["config.ini", "rascunho.ini", "/etc/rascunho.ini"]
+for path in paths:
+    try:
+        with open(path) as file:
+            config.read_file(file)
+        break
+    except FileNotFoundError:
+        pass
+
+if len(config.sections()) == 0:
+    raise Exception("Configuration is empty or were not found")
 
 env = config['meta']['env']