diff options
Diffstat (limited to 'src/ee/digikey')
-rw-r--r-- | src/ee/digikey/__init__.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/ee/digikey/__init__.py b/src/ee/digikey/__init__.py index 23569f9..3b1c52c 100644 --- a/src/ee/digikey/__init__.py +++ b/src/ee/digikey/__init__.py @@ -91,8 +91,7 @@ class DigikeyProduct(object): def __hash__(self): return self.part_number.__hash__() - def to_ini(self): - c = configparser.ConfigParser() + def to_ini(self, c: configparser.ConfigParser): c["overview"] = {}; overview = c["overview"] overview["part_number"] = self.part_number @@ -313,7 +312,8 @@ class DigikeyRepository(object): return p def save(self, product: DigikeyProduct): - y = product.to_ini() + c = self._make_configparser() + y = product.to_ini(c) filename = self.mpn_to_path(product.mpn) mk_parents(filename) with open(filename, "w") as f: @@ -322,8 +322,13 @@ class DigikeyRepository(object): def load_all(self): [self._load(path) for path in glob.glob(self._path + "/*.ini")] - def _load(self, path): + def _make_configparser(self): c = configparser.ConfigParser() + c.optionxform = str + return c + + def _load(self, path): + c = self._make_configparser() c.read(path) p = DigikeyProduct.from_ini(self._digikey, c) self._products[p.mpn] = p |