add the exclude_regex list option

This commit is contained in:
lilydjwg 2019-03-06 22:15:50 +08:00
parent 5b47391af0
commit e5d52a9762
2 changed files with 12 additions and 0 deletions

View file

@ -200,6 +200,12 @@ include_regex
Only consider version strings that match the given regex. The whole string Only consider version strings that match the given regex. The whole string
should match the regex. Be sure to use ``.*`` when you mean it! should match the regex. Be sure to use ``.*`` when you mean it!
exclude_regex
Don't consider version strings that match the given regex. The whole string
should match the regex. Be sure to use ``.*`` when you mean it! This option
has higher precedence that ``include_regex``; that is, if matched by this
one, it's excluded even it's also matched by ``include_regex``.
sort_version_key sort_version_key
Sort the version string using this key function. Choose between Sort the version string using this key function. Choose between
``parse_version`` and ``vercmp``. Default value is ``parse_version``. ``parse_version`` and ``vercmp``. Default value is ``parse_version``.

View file

@ -47,6 +47,12 @@ def apply_list_options(versions, conf):
versions = [x for x in versions versions = [x for x in versions
if pattern.fullmatch(x)] if pattern.fullmatch(x)]
pattern = conf.get('exclude_regex')
if pattern:
pattern = re.compile(pattern)
versions = [x for x in versions
if not pattern.fullmatch(x)]
ignored = set(conf.get('ignored', '').split()) ignored = set(conf.get('ignored', '').split())
if ignored: if ignored:
versions = [x for x in versions if x not in ignored] versions = [x for x in versions if x not in ignored]