Skip to content

Commit

Permalink
setoolsgui: Clean up criteria widget class names.
Browse files Browse the repository at this point in the history
Remove "criteria" and "widget" from final classes.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
  • Loading branch information
pebenito committed Dec 4, 2023
1 parent a393486 commit 80bd886
Show file tree
Hide file tree
Showing 48 changed files with 310 additions and 366 deletions.
6 changes: 3 additions & 3 deletions setoolsgui/widgets/boolquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def __init__(self, policy: setools.SELinuxPolicy, _, /, *,
#
# Set up criteria widgets
#
name = criteria.BooleanNameCriteriaWidget("Name", self.query, "name",
enable_regex=True,
parent=self.criteria_frame)
name = criteria.BooleanName("Name", self.query, "name",
enable_regex=True,
parent=self.criteria_frame)
name.setToolTip("Search for Booleans by name.")
name.setWhatsThis("<p>Search for Booleans by name.</p>")

Expand Down
4 changes: 2 additions & 2 deletions setoolsgui/widgets/commonquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def __init__(self, policy: setools.SELinuxPolicy, _, /, *,
name.setToolTip("Search for common permission sets by name.")
name.setWhatsThis("<p>Search for common permission set by name.</p>")

perms = criteria.PermissionCriteriaWidget("Permissions", self.query, "perms",
enable_equal=True)
perms = criteria.PermissionList("Permissions", self.query, "perms",
enable_equal=True)
perms.setToolTip("Search for common permission sets by permissions.")
perms.setWhatsThis("<p>Search for common permission set by permissions.</p>")

Expand Down
44 changes: 17 additions & 27 deletions setoolsgui/widgets/constraintquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ def __init__(self, policy: "setools.SELinuxPolicy", _, /, *,
<p>If a rule's has a one of the selected types, it will be returned.</p>
""")

user = criteria.UserNameWidget("User In Expression",
self.query,
"user",
enable_regex=True,
parent=self.criteria_frame)
user = criteria.UserName("User In Expression", self.query, "user",
enable_regex=True,
parent=self.criteria_frame)
user.setToolTip("Search for a user in the expression.")
user.setWhatsThis(
"""
Expand All @@ -50,11 +48,9 @@ def __init__(self, policy: "setools.SELinuxPolicy", _, /, *,
it will be returned.</p>
""")

role = criteria.RoleNameWidget("Role In Expression",
self.query,
"role",
enable_regex=True,
parent=self.criteria_frame)
role = criteria.RoleName("Role In Expression", self.query, "role",
enable_regex=True,
parent=self.criteria_frame)
role.setToolTip("Search for a role in the expression.")
role.setWhatsThis(
"""
Expand All @@ -64,13 +60,11 @@ def __init__(self, policy: "setools.SELinuxPolicy", _, /, *,
it will be returned.</p>
""")

type_ = criteria.TypeOrAttrNameWidget("Type In Expression",
self.query,
"type_",
mode=criteria.TypeOrAttrNameWidget.Mode.type_only,
enable_regex=True,
enable_indirect=False,
parent=self.criteria_frame)
type_ = criteria.TypeOrAttrName("Type In Expression", self.query, "type_",
mode=criteria.TypeOrAttrName.Mode.type_only,
enable_regex=True,
enable_indirect=False,
parent=self.criteria_frame)
type_.setToolTip("Search for a type in the expression.")
type_.setWhatsThis(
"""
Expand All @@ -80,10 +74,8 @@ def __init__(self, policy: "setools.SELinuxPolicy", _, /, *,
it will be returned.</p>
""")

tclass = criteria.ObjClassCriteriaWidget("Object Class",
self.query,
"tclass",
parent=self.criteria_frame)
tclass = criteria.ObjClassList("Object Class", self.query, "tclass",
parent=self.criteria_frame)
tclass.setToolTip("The object class(es) for constraint matching.")
tclass.setWhatsThis(
"""
Expand All @@ -93,12 +85,10 @@ def __init__(self, policy: "setools.SELinuxPolicy", _, /, *,
classes</p>
""")

perms = criteria.PermissionCriteriaWidget("Permission Set",
self.query,
"perms",
enable_equal=True,
enable_subset=True,
parent=self.criteria_frame)
perms = criteria.PermissionList("Permission Set", self.query, "perms",
enable_equal=True,
enable_subset=True,
parent=self.criteria_frame)
perms.setToolTip("The permission(s) for constraint matching.")
perms.setWhatsThis(
"""
Expand Down
14 changes: 7 additions & 7 deletions setoolsgui/widgets/criteria/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

from .. import models
from .combobox import ComboBoxWidget
from .list import ListCriteriaWidget
from .name import NameCriteriaWidget
from .list import ListWidget
from .name import NameWidget

# Regex for exact matches to types/attrs
VALIDATE_EXACT = r"[A-Za-z0-9._-]*"

__all__ = ("BooleanListCriteriaWidget", "BooleanNameCriteriaWidget", "BooleanState")
__all__ = ("BooleanList", "BooleanName", "BooleanState")


class BooleanListCriteriaWidget(ListCriteriaWidget):
class BooleanList(ListWidget):

"""A widget providing a QListView widget for selecting zero or more Booleans."""

Expand All @@ -33,7 +33,7 @@ def __init__(self, title: str, query, attrname: str, enable_equal: bool = True,
self.criteria_equal.setWhatsThis("<b>The selected Booleans must exactly match.</b>")


class BooleanNameCriteriaWidget(NameCriteriaWidget):
class BooleanName(NameWidget):

"""
Widget providing a QLineEdit for the user to enter a Boolean name, with
Expand Down Expand Up @@ -81,8 +81,8 @@ def __init__(self, title: str, query: setools.PolicyQuery, attrname: str, /, *,
mw = QtWidgets.QMainWindow()
window = QtWidgets.QWidget(mw)
layout = QtWidgets.QHBoxLayout(window)
widget1 = BooleanListCriteriaWidget("Test Booleans list", q1, "boolean", parent=window)
widget2 = BooleanNameCriteriaWidget("Test Booleans linedit", q2, "name", parent=window)
widget1 = BooleanList("Test Booleans list", q1, "boolean", parent=window)
widget2 = BooleanName("Test Booleans linedit", q2, "name", parent=window)
widget3 = BooleanState("Test Booleans State", q2, "default", enable_any=True, parent=window)
layout.addWidget(widget1)
layout.addWidget(widget2)
Expand Down
4 changes: 2 additions & 2 deletions setoolsgui/widgets/criteria/checkboxset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

from .criteria import CriteriaWidget

__all__ = ("CheckboxSetCriteriaWidget",)
__all__ = ("CheckboxSetWidget",)


class CheckboxSetCriteriaWidget(CriteriaWidget):
class CheckboxSetWidget(CriteriaWidget):

"""
Criteria selection widget presenting possible options as a series of checkboxes.
Expand Down
6 changes: 3 additions & 3 deletions setoolsgui/widgets/criteria/comboenum.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

E = typing.TypeVar("E", bound=enum.Enum)

__all__ = ('ComboEnumCriteria',)
__all__ = ('ComboEnumWidget',)


class ComboEnumCriteria(ComboBoxWidget, typing.Generic[E]):
class ComboEnumWidget(ComboBoxWidget, typing.Generic[E]):

"""Criteria selection widget presenting possible options a QComboxBox."""

Expand Down Expand Up @@ -48,7 +48,7 @@ class local_enum_class(enum.Enum):

app = QtWidgets.QApplication(sys.argv)
mw = QtWidgets.QMainWindow()
widget = ComboEnumCriteria("Test radio enum", q, "radioattrname", local_enum_class, parent=mw)
widget = ComboEnumWidget("Test radio enum", q, "radioattrname", local_enum_class, parent=mw)
widget.setToolTip("test tooltip")
widget.setWhatsThis("test whats this")
mw.setCentralWidget(widget)
Expand Down
4 changes: 2 additions & 2 deletions setoolsgui/widgets/criteria/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import setools

from .criteria import OptionsPlacement
from .name import NameCriteriaWidget
from .name import NameWidget

# Regex for exact matches to roles
VALIDATE_EXACT = r"[A-Za-z0-9._-]*"

__all__ = ("CommonName",)


class CommonName(NameCriteriaWidget):
class CommonName(NameWidget):

"""
Widget providing a QLineEdit that saves the input to the attributes
Expand Down
4 changes: 2 additions & 2 deletions setoolsgui/widgets/criteria/constraintype.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from PyQt6 import QtWidgets
import setools

from .checkboxset import CheckboxSetCriteriaWidget
from .checkboxset import CheckboxSetWidget

DEFAULT_CHECKED = ("constrain",)

__all__ = ('ConstrainType',)


class ConstrainType(CheckboxSetCriteriaWidget):
class ConstrainType(CheckboxSetWidget):

"""
Criteria selection widget presenting type enforcement rule types as a series
Expand Down
36 changes: 15 additions & 21 deletions setoolsgui/widgets/criteria/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ def __init__(self, title: str, query: setools.PolicyQuery, /,
self.top_layout.setContentsMargins(6, 6, 6, 6)
self.top_layout.setSpacing(3)

user = criteria.UserNameWidget("Context User",
self.query,
user_attrname,
enable_regex=True,
options_placement=criteria.OptionsPlacement.BELOW,
parent=self)
user = criteria.UserName("Context User", self.query, user_attrname,
enable_regex=True,
options_placement=criteria.OptionsPlacement.BELOW,
parent=self)
user.setToolTip("The user for context matching.")
user.setWhatsThis(
"""
Expand All @@ -51,12 +49,10 @@ def __init__(self, title: str, query: setools.PolicyQuery, /,
the user name instead of direct string comparison.</p>
""")

role = criteria.RoleNameWidget("Context Role",
self.query,
role_attrname,
enable_regex=True,
options_placement=criteria.OptionsPlacement.BELOW,
parent=self)
role = criteria.RoleName("Context Role", self.query, role_attrname,
enable_regex=True,
options_placement=criteria.OptionsPlacement.BELOW,
parent=self)
role.setToolTip("The role for context matching.")
role.setWhatsThis(
"""
Expand All @@ -66,15 +62,13 @@ def __init__(self, title: str, query: setools.PolicyQuery, /,
the role name instead of direct string comparison.</p>
""")

type_ = criteria.TypeOrAttrNameWidget("Context Type",
self.query,
type_attrname,
mode=criteria.TypeOrAttrNameWidget.Mode.type_only,
enable_regex=True,
enable_indirect=False,
required=False,
options_placement=criteria.OptionsPlacement.BELOW,
parent=self)
type_ = criteria.TypeOrAttrName("Context Type", self.query, type_attrname,
mode=criteria.TypeOrAttrName.Mode.type_only,
enable_regex=True,
enable_indirect=False,
required=False,
options_placement=criteria.OptionsPlacement.BELOW,
parent=self)
type_.setToolTip("The type for context matching.")
type_.setWhatsThis(
"""
Expand Down
4 changes: 2 additions & 2 deletions setoolsgui/widgets/criteria/fsuseruletype.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from PyQt6 import QtWidgets
import setools

from .checkboxset import CheckboxSetCriteriaWidget
from .checkboxset import CheckboxSetWidget

DEFAULT_CHECKED: typing.Final[tuple[str, ...]] = ("fs_use_xattr",)

__all__ = ('FSUseRuletype',)


class FSUseRuletype(CheckboxSetCriteriaWidget):
class FSUseRuletype(CheckboxSetWidget):

"""
Criteria selection widget presenting type enforcement rule types as a series
Expand Down
8 changes: 4 additions & 4 deletions setoolsgui/widgets/criteria/infiniband.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

from .criteria import OptionsPlacement
from .ipnetwork import IP_NetworkName
from .name import NameCriteriaWidget
from .ranged import RangedCriteriaWidget
from .name import NameWidget
from .ranged import RangedWidget

ENDPORT_VALIDATION: typing.Final[str] = r"[0-9]+"
PKEY_NUM_VALIDATION: typing.Final[str] = r"[0-9]+(-[0-9]+)?"

__all__ = ("IB_EndPortName", "IB_PKeyName", "IB_PKeySubnetPrefixName")


class IB_EndPortName(NameCriteriaWidget):
class IB_EndPortName(NameWidget):

"""
Widget providing a QLineEdit that saves the input to the attributes
Expand All @@ -34,7 +34,7 @@ def __init__(self, title: str, query: setools.PolicyQuery, attrname: str, /, *,
self.setToolTip("The endport of the infiniband port range.")


class IB_PKeyName(RangedCriteriaWidget):
class IB_PKeyName(RangedWidget):

"""
Widget providing a QLineEdit that saves the input to the attributes
Expand Down
4 changes: 2 additions & 2 deletions setoolsgui/widgets/criteria/ipnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import setools

from .criteria import OptionsPlacement
from .name import NameCriteriaWidget
from .name import NameWidget

IPV4_VALIDATION: typing.Final[str] = r"([0-9]{1,3}\.){3}[0-9]{1,3}(/[0-9]+)?"
IPV6_VALIDATION: typing.Final[str] = r"[0-9a-fA-F:/]+"
Expand All @@ -18,7 +18,7 @@
__all__ = ("IP_NetworkName",)


class IP_NetworkName(NameCriteriaWidget):
class IP_NetworkName(NameWidget):

"""
Base classs for widgets providing a QLineEdit that saves the input to the attributes
Expand Down
4 changes: 2 additions & 2 deletions setoolsgui/widgets/criteria/ipports.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import setools

from .criteria import OptionsPlacement
from .ranged import RangedCriteriaWidget
from .ranged import RangedWidget

VALIDATION = r"[0-9]+(-[0-9]+)?"

__all__ = ("IP_PortName",)


class IP_PortName(RangedCriteriaWidget):
class IP_PortName(RangedWidget):

"""
Widget providing a QLineEdit that saves the input to the attributes
Expand Down
4 changes: 2 additions & 2 deletions setoolsgui/widgets/criteria/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
EQUAL_DEFAULT_CHECKED = False
SUBSET_DEFAULT_CHECKED = False

__all__ = ('ListCriteriaWidget',)
__all__ = ('ListWidget',)


class ListCriteriaWidget(CriteriaWidget):
class ListWidget(CriteriaWidget):

"""Base class for QListView criteria widgets."""

Expand Down
6 changes: 3 additions & 3 deletions setoolsgui/widgets/criteria/mlslevelrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import setools

from .criteria import OptionsPlacement
from .ranged import RangedCriteriaWidget
from .ranged import RangedWidget

LEVEL_VALIDATION: typing.Final[str] = r"[A-Za-z0-9.,_:]+"
RANGE_VALIDATION: typing.Final[str] = r"[A-Za-z0-9.,_:]+ ?(- ?[A-Za-z0-9.,_:]+)?"

__all__ = ("MLSLevelName", "MLSRangeName")


class MLSLevelName(RangedCriteriaWidget):
class MLSLevelName(RangedWidget):

"""
Widget providing a QLineEdit that saves the input to the attributes
Expand All @@ -34,7 +34,7 @@ def __init__(self, title: str, query: setools.PolicyQuery, attrname: str, /, *,
options_placement=options_placement, parent=parent)


class MLSRangeName(RangedCriteriaWidget):
class MLSRangeName(RangedWidget):

"""
Widget providing a QLineEdit that saves the input to the attributes
Expand Down
Loading

0 comments on commit 80bd886

Please sign in to comment.