Example #1
0
class Flag(__enum_flag__):
    ''' '''
    __blank__ = str()
    __fn_names__ = staticmethod(
        __func_reduce__(__func_head__(map, __get_name__('__get_name__')),
                        ' '.join))
    __fn_agg__ = staticmethod(__ior_agg__)

    @property
    def __get_names__(self):
        ''' '''
        return self.__fn_names__(self.__matches__)

    @property
    def __matches__(self):
        ''' '''
        return filter(__func_head__(__contains__, self), self.__class__)

    @property
    def __get_name__(self):
        ''' '''
        return super().name or self.__blank__

    @property
    def name(self):
        ''' '''
        return self.__get_name__ or self.__get_names__

    @classmethod
    def Concat(cls, *flags):
        ''' '''
        return self.__fn_agg__(*flags)
Example #2
0
class Filter(object):
    ''' '''
    __slots__ = ()
    __default__ = __func_head__(filter, None)

    @classmethod
    def ByAttribute(cls, name):
        ''' ByAttribute uses name with the intent to: '''
        return __func_head__(filter, __get_name__(name))

    @classmethod
    def WithAttribute(cls, name):
        ''' WithAttribute uses name with the intent to: do something '''
        return __func_reduce__(cls.ByAttribute(name), cls.__default__)
Example #3
0
 def Selected(cls, predicate=None, function=None, *items):
     ''' '''
     mapper = __func_head__(map, function) if function else iter
     filtered = filter(predicate, items)
     return cls(*mapper(filtered))
Example #4
0
 def ByAttribute(cls, name):
     ''' ByAttribute uses name with the intent to: '''
     return __func_head__(filter, __get_name__(name))
Example #5
0
 def __matches__(self):
     ''' '''
     return filter(__func_head__(__contains__, self), self.__class__)