aboutsummaryrefslogtreecommitdiffhomepage
path: root/libs/rebulk/formatters.py
blob: 7175a54ab4ec41ddf09815a708e30f9cced64de4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Formatter functions to use in patterns.

All those function have last argument as match.value (str).
"""


def formatters(*chained_formatters):
    """
    Chain formatter functions.
    :param chained_formatters:
    :type chained_formatters:
    :return:
    :rtype:
    """

    def formatters_chain(input_string):  # pylint:disable=missing-docstring
        for chained_formatter in chained_formatters:
            input_string = chained_formatter(input_string)
        return input_string

    return formatters_chain


def default_formatter(input_string):
    """
    Default formatter
    :param input_string:
    :return:
    """
    return input_string