Commits

Lynn Rees committed 3bfcaf5

- tweaks

Comments (0)

Files changed (11)

 What's new in 0.5.7
 ===================
 
-- fix more issues with traversal
+- fix more issues with traversal
+
+What's new in 0.5.8
+===================
+
+- add new search expression support

knife/__init__.py

 
 __all__ = ('knife', 'activeknife', 'lazyknife', '__')
 
-__version__ = (0, 5, 7)
+__version__ = (0, 5, 8)
 from operator import truth
 from threading import local
 from collections import deque
-from fnmatch import translate
-from re import compile as rcompile
 
 from stuf.utils import memoize
-from parse import compile as pcompile
 from stuf.patterns import searcher
 
 SLOTS = (
 
 class _KnifeMixin(local):
 
-    '''base knife mixin'''
+    '''Base knife mixin.'''
 
     def __init__(self, ins, outs, **kw):
         super(_KnifeMixin, self).__init__()
 
     @staticmethod
     @memoize
-    def _pattern(pat, type, flags, t=translate, r=rcompile, p=pcompile):
+    def _pattern(pat, type, flags, s=searcher):
         # compile glob pattern into regex
-        return searcher((type, pat))
+        return s((type, pat))
 
     _REPR = '{0}.{1} ([IN: ({2}) => WORK: ({3}) => HOLD: ({4}) => OUT: ({5})])'
 
 
 class KChainknife(AppspaceKey):
 
-    '''base knife key'''
+    '''Base knife key.'''
 
     def __init__(*things, **kw):  # @NoSelf
         '''
 
 class KOutput(KChainknife):
 
-    '''output key'''
+    '''Output key.'''
 
     def __iter__():  # @NoSelf
         '''Iterate over outgoing things.'''

knife/_kmixins.py

 
 class KCompare(AppspaceKey):
 
-    '''
-    comparing knife key
-    '''
+    '''Comparing knife key.'''
 
     def all():  # @NoSelf
         '''
 
 class KMath(AppspaceKey):
 
-    '''mathing knife key'''
+    '''Mathing knife key.'''
 
     def average():  # @NoSelf
         '''
 
 class KOrder(AppspaceKey):
 
-    '''ordering knife mixin'''
+    '''Ordering knife key.'''
 
     def group():  # @NoSelf
         '''
 
 class KRepeat(AppspaceKey):
 
-    '''repeating knife key'''
+    '''Repeating knife key.'''
 
     def combinate(n):  # @NoSelf
         '''
 
 class KMap(AppspaceKey):
 
-    '''mapping knife key'''
+    '''Mapping knife key.'''
 
     def argmap(merge=False):  # @NoSelf
         '''
 
 class KFilter(AppspaceKey):
 
-    '''filtering knife key'''
+    '''Filtering knife key.'''
 
     def attrs(*names):  # @NoSelf
         '''
 
 class KReduce(AppspaceKey):
 
-    '''reducing knife key'''
+    '''Reducing knife key.'''
 
     def flatten():  # @NoSelf
         '''
 
 class KSlice(AppspaceKey):
 
-    '''slicing knife key'''
+    '''Slicing knife key.'''
 
     def at(n, default=None):  # @NoSelf
         '''
 
 class _LazyMixin(local):
 
-    '''lazy knife mixin'''
+    '''Lazy knife mixin.'''
 
     def __init__(self, *things, **kw):
         '''
 
 class _OutMixin(_LazyMixin):
 
-    '''lazy output mixin'''
+    '''Lazy output mixin.'''
 
     def _undo(self, snapshot=0):
         # clear everything
 
 class _CmpMixin(local):
 
-    '''comparing mixin'''
-
     @memoize
     def _all(self, a=all, m=map):
         # invoke worker on each item to yield truth
 
 class _MathMixin(local):
 
-    '''number mixin'''
-
     def _average(self, cnt=count, su=sum, td=truediv, t=tee):
         i1, i2 = t(self._iterable)
         return self._append(td(su(i1, 0.0), cnt(i2)))
 
 class _OrderMixin(local):
 
-    '''order mixin'''
-
     @memoize
     def _group(
         self, G=GroupBy, S=StopIteration, g=groupby, nx=next, sd=sorted,
 
 class _RepeatMixin(local):
 
-    '''repetition mixin'''
-
     def _combinate(self, n, cb=combinations):
         return self._xtend(cb(self._iterable, n))
 
 
 class _MapMixin(local):
 
-    '''mapping mixin'''
-
     @memoize
     def _argmap(self, curr, sm=starmap):
         call = self._worker
 
 class _FilterMixin(local):
 
-    '''filtering mixin'''
-
     @memoize
     def _attrs(
         self, names, A=AttributeError, S=StopIteration, ag=attrgetter, nx=next
 
 class _ReduceMixin(local):
 
-    '''reduce mixin'''
-
     def _flatten(
         self, A=AttributeError, S=StopIteration, T=TypeError, nx=next,
         st=strings, ii=isinstance,
 
 class _SliceMixin(local):
 
-    '''slicing mixin'''
-
     @memoize
     def _at(self, n, default, iz=islice, nx=next):
         return self._append(nx(iz(self._iterable, n, None), default))
 
 class KnifeMixin(local):
 
-    '''base knife mixin'''
+    '''Base knife mixin.'''
 
     def apply(self, worker, *args, **kw):
         '''
 
 class OutMixin(KnifeMixin):
 
-    '''output mixin'''
+    '''Output mixin.'''
 
     def __iter__(self):
         '''Iterate over outgoing things.'''
 # -*- coding: utf-8 -*-
-'''knife mixins'''
+'''knife mixins.'''
 
 from threading import local
 
 
 class CmpMixin(local):
 
-    '''
-    comparing knife mixin
-    '''
+    '''Comparing knife mixin.'''
 
     def all(self):
         '''
 
 class MathMixin(local):
 
-    '''mathing knife mixin'''
+    '''Mathing knife mixin.'''
 
     def average(self):
         '''
 
 class OrderMixin(local):
 
-    '''ordering knife mixin'''
+    '''Ordering knife mixin.'''
 
     def group(self):
         '''
 
 class RepeatMixin(local):
 
-    '''repeating knife mixin'''
+    '''Repeating knife mixin.'''
 
     def combinate(self, n):
         '''
 
 class MapMixin(local):
 
-    '''mapping knife mixin'''
+    '''Mapping knife mixin.'''
 
     def argmap(self, merge=False):
         '''
 
 class FilterMixin(local):
 
-    '''filtering knife mixin'''
+    '''Filtering knife mixin.'''
 
     def attrs(self, *names):
         '''
 
 class ReduceMixin(local):
 
-    '''reducing knife mixin'''
+    '''Reducing knife mixin.'''
 
     def flatten(self):
         '''
 
 class SliceMixin(local):
 
-    '''slicing knife mixin'''
+    '''Slicing knife mixin.'''
 
     def at(self, n, default=None):
         '''

tests/test_active.py

 
 class TestActive(
     unittest.TestCase, Mixin, FilterMixin, MapMixin, ReduceMixin, OrderMixin,
-    SliceMixin, RepeatMixin, MathMixin, CmpMixin
+    SliceMixin, RepeatMixin, MathMixin, CmpMixin,
 ):
 
     def setUp(self):

tests/test_lazy.py

 
 class TestLazy(
     unittest.TestCase, Mixin, CmpMixin, MapMixin, ReduceMixin, OrderMixin,
-    SliceMixin, RepeatMixin, MathMixin, FilterMixin
+    SliceMixin, RepeatMixin, MathMixin, FilterMixin,
 ):
 
     def setUp(self):
         from knife.lazy import sliceknife
         self.mclass = sliceknife
 
-
 if __name__ == '__main__':
     unittest.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.