49 lines
1.5 KiB
Diff
49 lines
1.5 KiB
Diff
50c50,52
|
|
< selector = ws '[' profile:p1 (ws profile)*:p2 ']' -> [p1] + p2
|
|
---
|
|
> profiles = '(' (ws? profile)*:p ws? ')' -> p
|
|
> group = profiles | profile
|
|
> selector = ws '[' (ws? group)*:p ws? ']' -> p
|
|
141c143,147
|
|
< for sense, profile in rule[1]:
|
|
---
|
|
> for group in rule[1]:
|
|
> if isinstance(group, list):
|
|
> user.append(group)
|
|
> continue
|
|
> sense, profile = group
|
|
161a168,169
|
|
> group_found = False
|
|
> group_match_found = False
|
|
163c171,177
|
|
< for sense, profile in partition_rule:
|
|
---
|
|
> for group in partition_rule:
|
|
> if isinstance(group, list):
|
|
> group_found = True
|
|
> if self._match_all(group, profiles):
|
|
> group_match_found = True
|
|
> continue
|
|
> sense, profile = group
|
|
172c186,189
|
|
< if not negative and (match_found or not positive):
|
|
---
|
|
> if not negative:
|
|
> if group_match_found or match_found:
|
|
> return True
|
|
> if not group_found and not positive:
|
|
174a192,204
|
|
>
|
|
> def _match_all(self, partition_rules, profiles):
|
|
> """Evaluate rules. Do they all match the profiles?
|
|
>
|
|
> :return Result True if all profiles match else False
|
|
> """
|
|
> def matches(sense, profile, profiles):
|
|
> return sense if profile in profiles else not sense
|
|
>
|
|
> for sense, profile in partition_rules:
|
|
> if not matches(sense, profile, profiles):
|
|
> return False
|
|
> return True
|