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
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 the version string using this key function. Choose between
``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
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())
if ignored:
versions = [x for x in versions if x not in ignored]