From 53c1de0a16586792d482265010af93725a010a5c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 6 Feb 2018 15:52:56 -0500 Subject: [PATCH] Handle hypphenated categories Some older equipment has this. Change-Id: I842f2cdaa6809ca2dfa0eaf20433b2cb4ab4092e --- pyghmi/ipmi/oem/lenovo/config.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/config.py b/pyghmi/ipmi/oem/lenovo/config.py index 779dab45..b9ceca7a 100644 --- a/pyghmi/ipmi/oem/lenovo/config.py +++ b/pyghmi/ipmi/oem/lenovo/config.py @@ -44,7 +44,8 @@ SIZE_COMMAND = [0x06] def _convert_syntax(raw): - return raw.replace('!', 'not').replace('||', 'or').replace('&&', 'and') + return raw.replace('!', 'not').replace('||', 'or').replace( + '&&', 'and').replace('-', '_') class _ExpEngine(object): @@ -56,11 +57,12 @@ class _ExpEngine(object): def lookup(self, category, setting): for optkey in self.cfg: opt = self.cfg[optkey] - if (opt['lenovo_id'] == category and + lid = opt['lenovo_id'].replace('-', '_') + if (lid == category and opt['lenovo_setting'] == setting): self.relatedsettings.add(optkey) return opt['lenovo_value'] - raise Exception('Cannot find {0}.{1}'.format(category, setting)) + return None def process(self, parsed): if isinstance(parsed, ast.UnaryOp) and isinstance(parsed.op, ast.Not):