in curator/helpers/date_ops.py [0:0]
def get_date_regex(timestring):
"""
:param timestring: An ``strftime`` pattern
:type timestring: :py:func:`~.time.strftime`
:returns: A regex string based on a provided :py:func:`~.time.strftime`
``timestring``.
:rtype: str
"""
logger = logging.getLogger(__name__)
prev, regex = ('', '')
logger.debug('Provided timestring = "%s"', timestring)
for idx, char in enumerate(timestring):
logger.debug('Current character: %s Array position: %s', char, idx)
if char == '%':
pass
elif char in date_regex() and prev == '%':
regex += r'\d{' + date_regex()[char] + '}'
elif char in ['.', '-']:
regex += "\\" + char
else:
regex += char
prev = char
logger.debug('regex = %s', regex)
return regex