Browse Source

Store order of configuration dicts

Previously, the order of elements in dicts in the configuration file was
not retained.  The most notable consequence of this is that plugins
would be loaded in an arbitrary order, which may have led to unexpected
or inconsistent results.  Now order is retained, so plugins will be
loaded in the order specified, and all is well in the world.
Clara Hobbs 7 years ago
parent
commit
7af31ebd4c
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      kayleevc/util.py

+ 2
- 1
kayleevc/util.py View File

8
 import hashlib
8
 import hashlib
9
 import os
9
 import os
10
 from argparse import ArgumentParser, Namespace
10
 from argparse import ArgumentParser, Namespace
11
+from collections import OrderedDict
11
 
12
 
12
 import requests
13
 import requests
13
 
14
 
82
     def _read_options_file(self):
83
     def _read_options_file(self):
83
         try:
84
         try:
84
             with open(self.opt_file, 'r') as f:
85
             with open(self.opt_file, 'r') as f:
85
-                self.options = json.load(f)
86
+                self.options = json.load(f, object_pairs_hook=OrderedDict)
86
                 self.options = Namespace(**self.options)
87
                 self.options = Namespace(**self.options)
87
         except FileNotFoundError:
88
         except FileNotFoundError:
88
             # Make an empty options namespace
89
             # Make an empty options namespace

Loading…
Cancel
Save