diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2017-09-30 23:21:32 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2017-09-30 23:21:32 +0200 |
commit | 40d38417360e7cd6602932e54c8b0e5fd3519355 (patch) | |
tree | 739c0b3dafa4d91cc57c7648f4ef7fa22227e05d /src/ee | |
parent | dbd1000240535771a45912a18b38ed240a4efa18 (diff) | |
download | ee-python-40d38417360e7cd6602932e54c8b0e5fd3519355.tar.gz ee-python-40d38417360e7cd6602932e54c8b0e5fd3519355.tar.bz2 ee-python-40d38417360e7cd6602932e54c8b0e5fd3519355.tar.xz ee-python-40d38417360e7cd6602932e54c8b0e5fd3519355.zip |
o Preventing ConfigParser from lower casing the keys in the ini file.
Thanks to https://stackoverflow.com/a/19359720/245614.
o Using different colors for the different log levels.
Diffstat (limited to 'src/ee')
-rw-r--r-- | src/ee/digikey/__init__.py | 13 | ||||
-rw-r--r-- | src/ee/tools/__init__.py | 4 |
2 files changed, 11 insertions, 6 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 diff --git a/src/ee/tools/__init__.py b/src/ee/tools/__init__.py index 136bdf1..68e3adc 100644 --- a/src/ee/tools/__init__.py +++ b/src/ee/tools/__init__.py @@ -30,10 +30,10 @@ class Log(object): print(color(msg, "orange")) def info(self, msg): - print(color(msg, "orange")) + print(color(msg, "white")) def debug(self, msg): - print(color(msg, "orange")) + print(color(msg, "grey")) log = Log() |