From e5d52a976286ec8d8913da59206de689b7e72ed6 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Wed, 6 Mar 2019 22:15:50 +0800 Subject: [PATCH] add the `exclude_regex` list option --- README.rst | 6 ++++++ nvchecker/get_version.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/README.rst b/README.rst index 48a7a66..b9fc86e 100644 --- a/README.rst +++ b/README.rst @@ -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``. diff --git a/nvchecker/get_version.py b/nvchecker/get_version.py index c7b28e5..70165bb 100644 --- a/nvchecker/get_version.py +++ b/nvchecker/get_version.py @@ -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]