Esempio n. 1
0
 def ReplaceWith(cls,
                 *patterns,
                 replacement=Characters.Empty,
                 flags=__default_flags__):
     ''' '''
     return __func_reduce__(
         *map(__func_tail__(cls.Replace, replacement, flags), patterns))
Esempio n. 2
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)
Esempio n. 3
0
 def Sequence(cls,
              *processes,
              from_unicode=True,
              split_second=False,
              split_end=False):
     ''' '''
     sequence = [cls.Unicode] if from_unicode else []
     if split_second: sequence.append(cls.Split)
     sequence.extend(processes)
     if split_end: sequence.append(cls.Split)
     return cls(__func_reduce__(*sequence))
Esempio n. 4
0
 def ReplaceWithPairs(cls, *pattern_replacements, flags=__default_flags__):
     ''' '''
     replacements = (cls.Replace(pattern, replacement, flags)
                     for pattern, replacement in pattern_replacements)
     return __func_reduce__(*replacements)
Esempio n. 5
0
 def WithAttribute(cls, name):
     ''' WithAttribute uses name with the intent to: do something '''
     return __func_reduce__(cls.ByAttribute(name), cls.__default__)
Esempio n. 6
0
def Never(*predicates):
    return __func_reduce__(__func_apply__(*predicates), any, __not__)
Esempio n. 7
0
def Invert(predicate):
    return __func_reduce__(predicate, __not__)
Esempio n. 8
0
class _fn:
    ''' '''
    EnumDict = staticmethod(__func_reduce__(enumerate, dict))