# HG changeset patch
# User Teemu Piippo <teemu@hecknology.net>
# Date 1600447662 -10800
# Node ID 60cac583b5df3f7e56fdcd63410b3d9053c587d6
# Parent  8e0782e20738f357639e873559fa4dc769bf4e49
fixed config not being properly loaded from script directory

diff -r 8e0782e20738 -r 60cac583b5df ldcheck.py
--- a/ldcheck.py	Sun Sep 06 16:42:02 2020 +0300
+++ b/ldcheck.py	Fri Sep 18 19:47:42 2020 +0300
@@ -17,10 +17,12 @@
 from os.path import realpath
 script_directory = Path(realpath(__file__)).parent
 
-def load_config(filename):
+def load_config(filename = None):
+    if filename is None:
+        filename = script_directory / 'ldcheck.cfg'
     from configobj import ConfigObj
     from copy import deepcopy
-    config = ConfigObj(filename, encoding = 'UTF8')
+    config = ConfigObj(str(filename), encoding = 'UTF8')
     read_config = deepcopy(config)
     if 'libraries' not in config:
         config['libraries'] = ['/path/to/ldraw']
@@ -142,7 +144,7 @@
         ),
     )
     args = parser.parse_args()
-    config = load_config('ldcheck.cfg')
+    config = load_config()
     for ldconfig_ldr_path in find_ldconfig_ldr_paths(config):
         with ldconfig_ldr_path.open() as ldconfig_ldr:
             load_colours(ldconfig_ldr)