2018-09-17 00:27:00 +00:00
|
|
|
#!/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:
|
|
|
|
"""
|
2020-05-20 15:29:39 +00:00
|
|
|
|
2018-09-17 00:27:00 +00:00
|
|
|
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
|
2020-05-20 15:29:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
def default_formatter(input_string):
|
|
|
|
"""
|
|
|
|
Default formatter
|
|
|
|
:param input_string:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
return input_string
|