def __init__(self, key, item): if key is None: self.key = self._default_hashkey elif not callable(key): self.key = getter(key) else: self.key = key self.item = item
def rowfunc(t): """ Rowfunc provides a function that can be mapped onto a sequence. >>> accounts = symbol('accounts', 'var * {name: string, amount: int}') >>> f = rowfunc(accounts['amount']) >>> row = ('Alice', 100) >>> f(row) 100 See Also: compute<Rowwise, Sequence> """ from toolz.itertoolz import getter indices = [t._child.fields.index(col) for col in t.fields] return getter(indices)
def test_getter(): assert getter(0)('Alice') == 'A' assert getter([0])('Alice') == ('A',) assert getter([])('Alice') == ()
def test_getter(): assert getter(0)('Alice') == 'A' assert getter([0])('Alice') == ('A', ) assert getter([])('Alice') == ()
def quick_scan(cls): """ Return a very quick list of block devices from a number of sources so we can quickly see changes. """ return pipe(fetch_device_list(), cmapcat(getter("paths")), sorted)