|
23 | 23 | See Also: |
24 | 24 | toolz.functoolz.curry |
25 | 25 | """ |
26 | | -from . import exceptions |
27 | | -from . import operator |
28 | 26 | import toolz |
| 27 | +from . import operator |
| 28 | +from toolz import ( |
| 29 | + comp, |
| 30 | + complement, |
| 31 | + compose, |
| 32 | + concat, |
| 33 | + concatv, |
| 34 | + count, |
| 35 | + curry, |
| 36 | + diff, |
| 37 | + dissoc, |
| 38 | + first, |
| 39 | + flip, |
| 40 | + frequencies, |
| 41 | + identity, |
| 42 | + interleave, |
| 43 | + isdistinct, |
| 44 | + isiterable, |
| 45 | + juxt, |
| 46 | + last, |
| 47 | + memoize, |
| 48 | + merge_sorted, |
| 49 | + peek, |
| 50 | + pipe, |
| 51 | + second, |
| 52 | + thread_first, |
| 53 | + thread_last, |
| 54 | +) |
| 55 | +from .exceptions import merge, merge_with |
29 | 56 |
|
| 57 | +accumulate = toolz.curry(toolz.accumulate) |
| 58 | +assoc = toolz.curry(toolz.assoc) |
| 59 | +assoc_in = toolz.curry(toolz.assoc_in) |
| 60 | +cons = toolz.curry(toolz.cons) |
| 61 | +countby = toolz.curry(toolz.countby) |
| 62 | +do = toolz.curry(toolz.do) |
| 63 | +drop = toolz.curry(toolz.drop) |
| 64 | +excepts = toolz.curry(toolz.excepts) |
| 65 | +filter = toolz.curry(toolz.filter) |
| 66 | +get = toolz.curry(toolz.get) |
| 67 | +get_in = toolz.curry(toolz.get_in) |
| 68 | +groupby = toolz.curry(toolz.groupby) |
| 69 | +interpose = toolz.curry(toolz.interpose) |
| 70 | +itemfilter = toolz.curry(toolz.itemfilter) |
| 71 | +itemmap = toolz.curry(toolz.itemmap) |
| 72 | +iterate = toolz.curry(toolz.iterate) |
| 73 | +join = toolz.curry(toolz.join) |
| 74 | +keyfilter = toolz.curry(toolz.keyfilter) |
| 75 | +keymap = toolz.curry(toolz.keymap) |
| 76 | +map = toolz.curry(toolz.map) |
| 77 | +mapcat = toolz.curry(toolz.mapcat) |
| 78 | +nth = toolz.curry(toolz.nth) |
| 79 | +partial = toolz.curry(toolz.partial) |
| 80 | +partition = toolz.curry(toolz.partition) |
| 81 | +partition_all = toolz.curry(toolz.partition_all) |
| 82 | +partitionby = toolz.curry(toolz.partitionby) |
| 83 | +pluck = toolz.curry(toolz.pluck) |
| 84 | +random_sample = toolz.curry(toolz.random_sample) |
| 85 | +reduce = toolz.curry(toolz.reduce) |
| 86 | +reduceby = toolz.curry(toolz.reduceby) |
| 87 | +remove = toolz.curry(toolz.remove) |
| 88 | +sliding_window = toolz.curry(toolz.sliding_window) |
| 89 | +sorted = toolz.curry(toolz.sorted) |
| 90 | +tail = toolz.curry(toolz.tail) |
| 91 | +take = toolz.curry(toolz.take) |
| 92 | +take_nth = toolz.curry(toolz.take_nth) |
| 93 | +topk = toolz.curry(toolz.topk) |
| 94 | +unique = toolz.curry(toolz.unique) |
| 95 | +update_in = toolz.curry(toolz.update_in) |
| 96 | +valfilter = toolz.curry(toolz.valfilter) |
| 97 | +valmap = toolz.curry(toolz.valmap) |
30 | 98 |
|
31 | | -def _should_curry(func): |
32 | | - if not callable(func) or isinstance(func, toolz.curry): |
33 | | - return False |
34 | | - nargs = toolz.functoolz.num_required_args(func) |
35 | | - if nargs is None or nargs > 1: |
36 | | - return True |
37 | | - return nargs == 1 and toolz.functoolz.has_keywords(func) |
38 | | - |
39 | | - |
40 | | -def _curry_namespace(ns): |
41 | | - return dict( |
42 | | - (name, toolz.curry(f) if _should_curry(f) else f) |
43 | | - for name, f in ns.items() if '__' not in name |
44 | | - ) |
45 | | - |
46 | | - |
47 | | -locals().update(toolz.merge( |
48 | | - _curry_namespace(vars(toolz)), |
49 | | - _curry_namespace(vars(exceptions)), |
50 | | -)) |
51 | | - |
52 | | -# Clean up the namespace. |
53 | | -del _should_curry |
54 | 99 | del exceptions |
55 | 100 | del toolz |
0 commit comments