Exemple #1
0
def _parse_format(text):
    """Parse stuff like format 6,5x9 cm"""
    format_pattern = re.compile(r"""
        (format)\s
        (?P<a>[\d,\.]+?)   # Digits, comma or dot, captured as group
        x                  # x
        (?P<b>[\d,\.]+?)   # Same
        \s?cm              # Whitespace, cm
        """, re.X)
    match = re.search(format_pattern, text)
    if match:
        new_value = commonprocessors._pattern_to_size(match).strip()
        return new_value
    else:
        return None