From 203e80ef0aa1f437ea4e5911f3e1ada5ca335c57 Mon Sep 17 00:00:00 2001 From: Jan Vcelak Date: Mon, 28 Jan 2013 18:08:38 +0100 Subject: [PATCH] fix device matching if the multiple profiles are merged --- tuned/hardware/device_matcher.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tuned/hardware/device_matcher.py b/tuned/hardware/device_matcher.py index 873d6ed..bb3d7a8 100644 --- a/tuned/hardware/device_matcher.py +++ b/tuned/hardware/device_matcher.py @@ -11,7 +11,7 @@ class DeviceMatcher(object): The rules have a syntax of shell-style wildcards and are either positive or negative. The negative rules are prefixed with an exclamation mark. """ - def match(self, rules_str, device_name): + def match(self, rules, device_name): """ Match a device against the specification in the profile. @@ -19,7 +19,9 @@ class DeviceMatcher(object): which matches all devices is added. The device matches if and only if it matches some positive rule, but no negative rule. """ - rules = re.split(r"\s|,\s*", rules_str) + if isinstance(rules, basestring): + rules = re.split(r"\s|,\s*", rules) + positive_rules = filter(lambda rule: not rule.startswith("!"), rules) negative_rules = [rule[1:] for rule in rules if rule not in positive_rules] @@ -39,14 +41,14 @@ class DeviceMatcher(object): return matches - def match_list(self, rules_str, device_list): + def match_list(self, rules, device_list): """ Match a device list against the specification in the profile. Returns the list, which is a subset of devices which match. """ matching_devices = [] for device in device_list: - if self.match(rules_str, device): + if self.match(rules, device): matching_devices.append(device) return matching_devices