summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2017-05-10 17:21:35 +0200
committerMichał Górny <mgorny@gentoo.org>2017-05-16 19:11:32 +0200
commit0cfab505ad867ed3418b0dad8c4f2efa52acb1e7 (patch)
tree4ba40458ba4f4cdaf647e5486810e2b9a5ba2c9d /eclass
parentdev-python/repoze-sphinx-autointerface: Use dot-notation for python_moduleinto (diff)
downloadgentoo-0cfab505ad867ed3418b0dad8c4f2efa52acb1e7.tar.gz
gentoo-0cfab505ad867ed3418b0dad8c4f2efa52acb1e7.tar.bz2
gentoo-0cfab505ad867ed3418b0dad8c4f2efa52acb1e7.zip
python-utils-r1.eclass: _python_impl_matches for impl-pattern matching
Introduce a _python_impl_matches() function that commonizes the pattern matching behavior used throughout python-r1 & python-single-r1. Having a single implementation makes future extensions much easier.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/python-utils-r1.eclass24
1 files changed, 24 insertions, 0 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 863051337f0b..a9ae22c6d154 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -149,6 +149,30 @@ _python_set_impls() {
fi
}
+# @FUNCTION: _python_impl_matches
+# @USAGE: <impl> <pattern>...
+# @INTERNAL
+# @DESCRIPTION:
+# Check whether the specified <impl> matches at least one
+# of the patterns following it. Return 0 if it does, 1 otherwise.
+#
+# <impl> should be in PYTHON_COMPAT form. The patterns are fnmatch-style
+# patterns.
+_python_impl_matches() {
+ [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters"
+
+ local impl=${1} pattern
+ shift
+
+ for pattern; do
+ if [[ ${impl} == ${pattern} ]]; then
+ return 0
+ fi
+ done
+
+ return 1
+}
+
# @ECLASS-VARIABLE: PYTHON
# @DEFAULT_UNSET
# @DESCRIPTION: