fixed config not being properly loaded from script directory

Fri, 18 Sep 2020 19:47:42 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 18 Sep 2020 19:47:42 +0300
changeset 116
60cac583b5df
parent 115
8e0782e20738
child 117
178d6e54694f

fixed config not being properly loaded from script directory

ldcheck.py file | annotate | diff | comparison | revisions
--- 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)

mercurial