2018-09-17 00:27:00 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
size property
|
|
|
|
"""
|
|
|
|
import re
|
|
|
|
|
|
|
|
from rebulk import Rebulk
|
|
|
|
|
|
|
|
from ..common.validators import seps_surround
|
2018-10-06 17:18:55 +00:00
|
|
|
from ..common import dash
|
2018-09-17 00:27:00 +00:00
|
|
|
|
|
|
|
|
2018-10-06 17:18:55 +00:00
|
|
|
def size():
|
2018-09-17 00:27:00 +00:00
|
|
|
"""
|
|
|
|
Builder for rebulk object.
|
|
|
|
:return: Created Rebulk object
|
|
|
|
:rtype: Rebulk
|
|
|
|
"""
|
2018-10-06 17:18:55 +00:00
|
|
|
|
|
|
|
def format_size(value):
|
|
|
|
"""Format size using uppercase and no space."""
|
|
|
|
return re.sub(r'(?<=\d)[.](?=[^\d])', '', value.upper())
|
|
|
|
|
|
|
|
rebulk = Rebulk().regex_defaults(flags=re.IGNORECASE, abbreviations=[dash])
|
2018-09-17 00:27:00 +00:00
|
|
|
rebulk.defaults(name='size', validator=seps_surround)
|
2018-10-06 17:18:55 +00:00
|
|
|
rebulk.regex(r'\d+\.?[mgt]b', r'\d+\.\d+[mgt]b', formatter=format_size, tags=['release-group-prefix'])
|
2018-09-17 00:27:00 +00:00
|
|
|
|
|
|
|
return rebulk
|