Source

callchain / callchain / queue / keys.py

# -*- coding: utf-8 -*-
'''queuing chainlet keys'''

from callchain.chainlet.keys import KChainlet


class KMath(KChainlet):

    '''math key'''

    def average():  # @NoSelf
        '''average of all incoming things'''

    def fsum():  # @NoSelf
        '''add incoming things together'''

    def max():  # @NoSelf
        '''
        find maximum thing in incoming things, optionally using current
        call as key function
        '''

    def median():  # @NoSelf
        '''median of all incoming things'''

    def min():  # @NoSelf
        '''find minimum thing in incoming things using call as key function'''

    def minmax():  # @NoSelf
        '''minimum and maximum things among all incoming things'''

    def mode():  # @NoSelf
        '''mode of all incoming things'''

    def uncommon():  # @NoSelf
        '''least common incoming thing'''

    def frequency():  # @NoSelf
        '''frequency of each incoming thing'''

    def statrange():  # @NoSelf
        '''statistical range of all incoming things'''

    def sum(start=0):  # @NoSelf
        '''
        add all incoming things together

        @param start: starting number (default: 0)
        '''


class KTruth(KChainlet):

    '''truth key'''

    def all():  # @NoSelf
        '''if `all` incoming things are `True`'''

    def any():  # @NoSelf
        '''if `any` incoming things are `True`'''

    def contains(thing):  # @NoSelf
        '''
        if `thing` is in incoming things

        @param thing: some thing
        '''

    def quantify():  # @NoSelf
        '''how many times call is `True` for incoming things'''


class KReduce(KChainlet):

    '''reduce key'''

    def merge():  # @NoSelf
        '''flatten nested but ordered incoming things'''

    def smash():  # @NoSelf
        '''flatten deeply nested incoming things'''

    def pairwise():  # @NoSelf
        '''every two incoming things as a tuple'''

    def reduce(initial=None):  # @NoSelf
        '''
        reduce incoming things to one thing using call (from left side of
        incoming things)

        @param initial: initial thing (default: None)
        '''

    def reduce_right(initial=None):  # @NoSelf
        '''
        reduce incoming things to one thing from right side of incoming things
        using call

        @param initial: initial thing (default: None)
        '''

    def roundrobin():  # @NoSelf
        '''interleave incoming things into one thing'''

    def zip():  # @NoSelf
        '''
        smash incoming things into one single thing, pairing things by iterable
        position
        '''


class KRandom(KChainlet):

    '''random key'''

    def choice():  # @NoSelf
        '''random choice of/from incoming things'''

    def sample(n):  # @NoSelf
        '''
        random sampling drawn from `n` incoming things

        @param n: number of incoming things
        '''

    def shuffle():  # @NoSelf
        '''randomly order incoming things'''


class KOrder(KChainlet):

    '''ordering key'''

    def group():  # @NoSelf
        '''
        group incoming things, optionally using current call for key function
        '''

    def grouper(n, fill=None):  # @NoSelf
        '''
        split incoming things into sequences of length `n`, using `fill` thing
        to pad incomplete sequences

        @param n: number of things
        @param fill: fill thing (default: None)
        '''

    def reverse():  # @NoSelf
        '''reverse order of incoming things'''

    def sort():  # @NoSelf
        '''
        sort incoming things, optionally using current call as key function
        '''


class KCombine(KChainlet):

    '''combination key'''

    def combinations(r):  # @NoSelf
        '''
        `r` length slices of incoming things

        @param r: length of combinations
        '''

    def permutations(r):  # @NoSelf
        '''
        successive `r` length permutations of incoming things

        @param r: length of permutations
        '''

    def product(n=1):  # @NoSelf
        '''
        nested for each loops repeated `n` times

        @param n: number of repetitions (default: 1)
        '''

class KDelay(KChainlet):

    '''delayed map key'''

    def delay_each(wait):  # @NoSelf
        '''
        invoke call with passed arguments, keywords in incoming things after
        delay `wait`

        @param wait: time in seconds
        '''

    def delay_invoke(name, wait):  # @NoSelf
        '''
        invoke method `name` on each incoming thing with passed arguments,
        keywords after delay `wait` but return incoming thing instead if method
        returns `None`

        @param name: name of method
        @param wait: time in seconds
        '''

    def delay_map(wait):  # @NoSelf
        '''
        invoke call on each incoming thing after delay `wait`

        @param wait: time in seconds
        '''


class KRepeat(KChainlet):

    '''repetition key'''

    def copy():  # @NoSelf
        '''copy each incoming thing'''

    def padnone():  # @NoSelf
        '''repeat incoming things and then `None` indefinitely'''

    def range(start, stop=0, step=1):  # @NoSelf
        '''
        put sequence of numbers in incoming things

        @param start: number to start with
        @param stop: number to stop with (default: 0)
        @param step: number of steps to advance per iteration (default: 1)
        '''

    def repeat(n):  # @NoSelf
        '''
        repeat incoming things `n` times

        @param n: number of times to repeat
        '''

    def times(n=None):  # @NoSelf
        '''
        repeat call with incoming things `n` times

        @param n: repeat call n times on incoming things (default: None)
        '''


class KMap(KChainlet):

    '''mapping key'''

    def map():  # @NoSelf
        '''invoke call on each incoming thing'''

    def invoke(name):  # @NoSelf
        '''
        invoke method `name` on each incoming thing with passed arguments,
        keywords but return incoming thing instead if method returns `None`

        @param name: name of method
        '''

    def each():  # @NoSelf
        '''invoke call with passed arguments, keywords in incoming things'''

    def starmap():  # @NoSelf
        '''invoke call on each sequence of incoming things'''

    def items():  # @NoSelf
        '''invoke call on each mapping to get key, value pairs'''


class KCollect(KChainlet):

    '''collection key'''

    def deepmembers():  # @NoSelf
        '''collect object members from incoming things and their bases'''

    def members():  # @NoSelf
        '''collect object members from incoming things'''

    def pick(*names):  # @NoSelf
        '''collect object attributes from incoming things by their `*names`'''

    def pluck(*keys):  # @NoSelf
        '''collect object items from incoming things by item `*keys`'''


class KSet(KChainlet):

    '''set uniqueness key'''

    def difference():  # @NoSelf
        '''difference between incoming things'''

    def symmetric_difference():  # @NoSelf
        '''symmetric difference between incoming things'''

    def disjointed():  # @NoSelf
        '''disjoint between incoming things'''

    def intersection():  # @NoSelf
        '''intersection between incoming things'''

    def subset():  # @NoSelf
        '''incoming things that are subsets of incoming things'''

    def superset():  # @NoSelf
        '''incoming things that are supersets of incoming things'''

    def union():  # @NoSelf
        '''union between incoming things'''

    def unique():  # @NoSelf
        '''
        list unique incoming things, preserving order and remember all incoming
        things ever seen
        '''


class KSlice(KChainlet):

    '''slicing key'''

    def nth(n, default=None):  # @NoSelf
        '''
        `nth` incoming thing or default thing

        @param n: number of things
        @param default: default thing (default: None)
        '''

    def initial():  # @NoSelf
        '''all incoming things except the last thing'''

    def rest():  # @NoSelf
        '''all incoming things except the first thing'''

    def snatch(n):  # @NoSelf
        '''
        last `n` things of incoming things

        @param n: number of things
        '''

    def take(n):  # @NoSelfs
        '''
        first `n` things of incoming things

        @param n: number of things
        '''


class KFilter(KChainlet):

    '''filter key'''

    def compact():  # @NoSelf
        '''strip "untrue" things from incoming things'''

    def filter():  # @NoSelf
        '''incoming things for which call is `True`'''

    def find():  # @NoSelf
        '''first incoming thing for which call is `True`'''

    def partition():  # @NoSelf
        '''
        split incoming things into `True` and `False` things based on results
        of call
        '''

    def reject():  # @NoSelf
        '''incoming things for which call is `False`'''

    def without(*things):  # @NoSelf
        '''strip things from incoming things'''
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.