2018-09-17 00:27:00 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
size property
|
|
|
|
"""
|
|
|
|
import re
|
|
|
|
|
|
|
|
from rebulk import Rebulk
|
|
|
|
|
2018-10-06 17:18:55 +00:00
|
|
|
from ..common import dash
|
2020-05-20 15:29:39 +00:00
|
|
|
from ..common.quantity import Size
|
|
|
|
from ..common.pattern import is_disabled
|
|
|
|
from ..common.validators import seps_surround
|
2018-09-17 00:27:00 +00:00
|
|
|
|
|
|
|
|
2020-05-20 15:29:39 +00:00
|
|
|
def size(config): # pylint:disable=unused-argument
|
2018-09-17 00:27:00 +00:00
|
|
|
"""
|
|
|
|
Builder for rebulk object.
|
2020-05-20 15:29:39 +00:00
|
|
|
|
|
|
|
:param config: rule configuration
|
|
|
|
:type config: dict
|
2018-09-17 00:27:00 +00:00
|
|
|
:return: Created Rebulk object
|
|
|
|
:rtype: Rebulk
|
|
|
|
"""
|
2020-05-20 15:29:39 +00:00
|
|
|
rebulk = Rebulk(disabled=lambda context: is_disabled(context, 'size'))
|
|
|
|
rebulk.regex_defaults(flags=re.IGNORECASE, abbreviations=[dash])
|
2018-09-17 00:27:00 +00:00
|
|
|
rebulk.defaults(name='size', validator=seps_surround)
|
2020-05-20 15:29:39 +00:00
|
|
|
rebulk.regex(r'\d+-?[mgt]b', r'\d+\.\d+-?[mgt]b', formatter=Size.fromstring, tags=['release-group-prefix'])
|
2018-09-17 00:27:00 +00:00
|
|
|
|
|
|
|
return rebulk
|