/usr/share/pyshared/MoinMoin/util/dataset.py is in python-moinmoin 1.9.3-1ubuntu2.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | # -*- coding: iso-8859-1 -*-
"""
MoinMoin - Datasets
Datasets are used by the DataBrowserWidget, and with the
statistics code.
@copyright: 2002 Juergen Hermann <jh@web.de>
@license: GNU GPL, see COPYING for details.
"""
class Column:
""" Meta-data for a column.
"""
_SLOTS = [
('label', ''),
('sortable', 0),
('hidden', 0),
('align', ''),
('autofilter', 0),
]
def __init__(self, name, **kw):
""" Init a column
keys in kw that not in slots are ignored.
@param name: column name, unicode or ascii
@param kw: column meta data, unicode or ascii
"""
self.name = name
for slot, defval in self._SLOTS:
setattr(self, slot, kw.get(slot, defval))
class Dataset:
""" Base dataset.
Holds a 2-dimensional data set (m rows of n columns) and associated
meta-data (column titles, etc.).
Note: Dataset rows and column must contain only ascii or Unicode values!
"""
def __init__(self, data_id=None):
self.columns = []
self.data = []
self._pos = 0
self.data_id = data_id
def __len__(self):
return len(self.data)
def reset(self):
""" Reset iterator to start.
"""
self._pos = 0
def next(self):
""" Return next row as a tuple, ordered by columns.
"""
if self._pos >= len(self):
return None
row = self.data[self._pos]
self._pos += 1
return row
def addRow(self, row):
""" Add a row to the dataset.
"""
self.data.append(row)
class TupleDataset(Dataset):
""" A dataset that stores tuples.
"""
class DictDataset(Dataset):
""" A dataset that stores dicts as the rows.
"""
def next(self):
row = Dataset.next(self)
return tuple([row[col.name] for col in self.columns])
class DbDataset(Dataset):
pass
|