1. Lynn Rees
  2. knife

Commits

Lynn Rees  committed 7c7aa5c

- fix mapping

  • Participants
  • Parent commits 3978bb9
  • Branches pu

Comments (0)

Files changed (6)

File knife/_active.py

View file
  • Ignore whitespace
         # clear everything
         self.clear()
         # clear snapshots
-        self._clearsp()
+        self._history.clear()
         # revert to baseline snapshot of incoming things
         self._in.extend(loads_(self._baseline))
         return self
         # clear everything
         self.clear()
         # clear snapshots
-        self._clearsp()
+        self._history.clear()
         # clear baseline
         self._baseline = None
         # restore original snapshot of incoming things

File knife/_base.py

View file
  • Ignore whitespace
         return s((type, pat), flags)
 
     _REPR = '{0}.{1} ([IN: ({2}) => WORK: ({3}) => HOLD: ({4}) => OUT: ({5})])'
-
-    def _clearsp(self):
-        # clear fetch snapshots
-        self._history.clear()
-        return self

File knife/_lazy.py

View file
  • Ignore whitespace
         # clear everything
         self.clear()
         # clear snapshots
-        self._clearsp()
+        self._history.clear()
         # revert to baseline snapshot of incoming things
         self._in, self._baseline = tee_(self._baseline)
         return self
         # clear everything
         self.clear()
         # clear snapshots
-        self._clearsp()
+        self._history.clear()
         # clear baseline
         self._baseline = None
         # restore original snapshot of incoming things

File knife/_mixins.py

View file
  • Ignore whitespace
 
     @memoize
     def _mapping(
-        self, key, value, unchain, mapmerge, ky=keys, it=items, vl=values,
-        sm=starmap, m=map, ci=chain.from_iterable,
+        self, key, value, ky=keys, it=items, vl=values,
+        sm=starmap, m=map, ci=chain.from_iterable, aget=attrgetter,
     ):
-        if mapmerge:
-            self._wrapper = dict
-        if unchain:
-            aget = attrgetter('maps')
-            self._iterable = (aget(i) for i in self._iterable)
         if key:
             return self._xtend(m(self._identity, ci(m(ky, self._iterable))))
         elif value:

File knife/mixins.py

View file
  • Ignore whitespace
         with self._chain:
             return self._map()
 
-    def mapping(self, keys=False, values=False, unchain=False, mapmerge=False):
+    def mapping(self, keys=False, values=False):
         '''
         Run :meth:`worker` on incoming :term:`mapping` things.
 
             function in Underscore.php
         '''
         with self._chain:
-            return self._mapping(keys, values, unchain, mapmerge)
+            return self._mapping(keys, values)
 
 
 class FilterMixin(local):

File tests/mixins.py

View file
  • Ignore whitespace
         self.assertEqual(
             self.mclass(
                 dict([(1, 2), (2, 3), (3, 4)]), dict([(1, 2), (2, 3), (3, 4)])
-            ).mapping(mapmerge=True).get(),
+            ).mapping().wrap(dict).get(),
             dict([(1, 2), (2, 3), (3, 4)]),
         )
 
         self.assertEqual(queue.peek(), [1, 2, 3, 4, 5, 6, 1, 2, 3, 1])
         queue.original()
         self.assertEqual(queue.peek(), [1, 2, 3])
+        self.assertRaises(IndexError, lambda: queue.undo().undo())
 
     def test_wrap(self):
         self.assertIsInstance(