diff --git a/adx/logger.py b/adx/logger.py index 9117bfb..85708af 100644 --- a/adx/logger.py +++ b/adx/logger.py @@ -36,14 +36,14 @@ def types(self): def set_up_table(self): self.tables_cols = {} for prs in self.parsers: - self.tables_cols[prs] = [pf[0] for pf in prs.parse_funcs] + self.tables_cols[prs] = [pi for pi in prs.info_list] def get_info_entry(self, item, parser): """ Parse the item information following the table column. """ info = parser(item) entry = () - for tc in self.tables_cols[parser._type]: + for tc in self.tables_cols[parser.item_type]: entry += (info[tc],) return entry diff --git a/adx/parser/parser.py b/adx/parser/parser.py index 1e106f7..8ebc8c2 100644 --- a/adx/parser/parser.py +++ b/adx/parser/parser.py @@ -34,13 +34,9 @@ class ParserBase: Atributes --------- - parse_funs: list of tuple - The request information name and the method/callable functions to get - the information. The first element is the request information name (in - ADX this attribute will be used as the database column name.), and the - second value is the callable fucntions that parse the information. - One should organize the parse functions accordingly. - The default is an empty list. + info_list: list + The list of information that parser returns. This will be used in the + logger. reader: instance An item instance provides the methods to interpret the data. """ @@ -52,7 +48,7 @@ def __init__(self, item_type, extensions, reader_cls=None, reader_args={}): self.reader_cls = reader_cls self.reader_args = reader_args self.reader = None - self.parse_funcs = [] + self.info_list = [] def __call__(self, itemname, **kwargs): """ High-level parse_info method. @@ -69,15 +65,7 @@ def __call__(self, itemname, **kwargs): This if for the general purpose, however, it can be redefined in the subclass. """ - if not self.check_type(itemname): - return None - else: - if parse_funcs == []: - raise ValueError("Parser needs parse functions.") - result = {} - for k, f in self.parse_funs: - result[k] = f(itemname, **kwargs) - return result + raise NotImplementedError def check_type(self, itemname): """ User defined item type checker.