2018-09-17 08:27:00 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
edition property
|
|
|
|
"""
|
2022-01-06 09:12:46 +08:00
|
|
|
from rebulk import Rebulk
|
2018-09-17 08:27:00 +08:00
|
|
|
from rebulk.remodule import re
|
|
|
|
|
|
|
|
from ..common import dash
|
2020-05-20 23:29:39 +08:00
|
|
|
from ..common.pattern import is_disabled
|
2018-09-17 08:27:00 +08:00
|
|
|
from ..common.validators import seps_surround
|
2022-01-06 09:12:46 +08:00
|
|
|
from ...config import load_config_patterns
|
2018-09-17 08:27:00 +08:00
|
|
|
|
|
|
|
|
2020-05-20 23:29:39 +08:00
|
|
|
def edition(config): # pylint:disable=unused-argument
|
2018-09-17 08:27:00 +08:00
|
|
|
"""
|
|
|
|
Builder for rebulk object.
|
2020-05-20 23:29:39 +08:00
|
|
|
|
|
|
|
:param config: rule configuration
|
|
|
|
:type config: dict
|
2018-09-17 08:27:00 +08:00
|
|
|
:return: Created Rebulk object
|
|
|
|
:rtype: Rebulk
|
|
|
|
"""
|
2020-05-20 23:29:39 +08:00
|
|
|
rebulk = Rebulk(disabled=lambda context: is_disabled(context, 'edition'))
|
2022-01-06 09:12:46 +08:00
|
|
|
rebulk.regex_defaults(flags=re.IGNORECASE, abbreviations=[dash]).string_defaults(ignore_case=True)
|
2018-09-17 08:27:00 +08:00
|
|
|
rebulk.defaults(name='edition', validator=seps_surround)
|
|
|
|
|
2022-01-06 09:12:46 +08:00
|
|
|
load_config_patterns(rebulk, config.get('edition'))
|
2018-09-17 08:27:00 +08:00
|
|
|
|
|
|
|
return rebulk
|