| Server IP : 172.67.193.39 / Your IP : 216.73.216.217 Web Server : Apache System : Linux sr32.hostlife.net 6.12.0-124.52.3.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Sat May 2 09:06:54 EDT 2026 x86_64 User : golfb689 ( 1071) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib64/python3.12/site-packages/setools/ |
Upload File : |
# Copyright 2015, Tresys Technology, LLC
#
# SPDX-License-Identifier: LGPL-2.1-only
#
from collections.abc import Iterable
import typing
from . import mixins, policyrep, query
__all__: typing.Final[tuple[str, ...]] = ("CategoryQuery",)
class CategoryQuery(mixins.MatchAlias, mixins.MatchName, query.PolicyQuery):
"""
Query MLS Categories
Parameter:
policy The policy to query.
Keyword Parameters/Class attributes:
name The name of the category to match.
name_regex If true, regular expression matching will
be used for matching the name.
alias The alias name to match.
alias_regex If true, regular expression matching
will be used on the alias names.
"""
def results(self) -> Iterable[policyrep.Category]:
"""Generator which yields all matching categories."""
self.log.info(f"Generating category results from {self.policy}")
self._match_name_debug(self.log)
self._match_alias_debug(self.log)
for cat in self.policy.categories():
if not self._match_name(cat):
continue
if not self._match_alias(cat):
continue
yield cat