def __init__(self, *args, **kwargs): self.colnames = kwargs.pop('colnames', ()) """Column names.""" self.name = kwargs.pop('name', 'data_table') """Store the name os the 'DataTable' object.""" self.capacity = kwargs.pop('capacity', 0) """Store the max capacity of rows in the container.""" self.firstrow_header = kwargs.pop('firstrow_header', False) """Identify if the firstrow is a header line.""" # input_converter = kwargs.pop('input_converter', True) # """Disable input conversion to 'tuple' object (more speed).""" if kwargs: raise DataTableError("Unexpected keyword arguments (%r)" % kwargs) self.events = SDict(onAppend=Signal(), onInsert=Signal()) if self.capacity: # Connect events to handlers. self.events.onAppend.append(self._capacity_checker) self.events.onInsert.append(self._capacity_checker) self.list = list() self.extend(args) if args and not self.colnames: if self.firstrow_header: self.colnames = tuple(self.list.pop(0)) else: self.colnames = tuple("C%i" % x for x in range(len(self.list[0])))
def inner(row): sdict = SDict(zip(colnames, row)) return method(sdict)