diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c3c8d552..883edaa5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,24 +27,21 @@ jobs: matrix: build-opts: - - {python: '3.6', tox: python3.6} - - {python: '3.7', tox: python3.7} - - {python: '3.8', tox: python3.8} - {python: '3.9', tox: python3.9} - {python: '3.10', tox: python3.10} - {python: '3.11', tox: python3.11} - - {python: '3.6', tox: pep8} - - {python: '3.6', tox: lint} - - {python: '3.6', tox: mypy} - - {python: '3.6', tox: coverage} - - {python: '3.6', tox: install} + - {python: '3.11', tox: pep8} + - {python: '3.11', tox: lint} + - {python: '3.11', tox: mypy} + - {python: '3.11', tox: coverage} + - {python: '3.11', tox: install} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # This should be the minimum required Python version to build refpolicy. - name: Set up Python ${{ matrix.build-opts.python }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.build-opts.python }} diff --git a/ChangeLog b/ChangeLog index e0f43e2b..0124f138 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +*setools-4-4.4 (07 Dec 2023) + * Update for compiling with libsepol 3.6. + * Update apol to use fully specified PyQt enums. + * Correct minor code lint issues. + *setools-4-4.3 (27 Jul 2023) * Fix compilation with Cython 3.0.0. * Improve man pages. diff --git a/setools/diff/difference.py b/setools/diff/difference.py index d23bffab..315e6012 100644 --- a/setools/diff/difference.py +++ b/setools/diff/difference.py @@ -129,8 +129,9 @@ class Wrapper(ABC, Generic[T]): __slots__ = ("origin", "key") - def __init__(self, symbol: T) -> None: - pass + def __init__(self, origin: T, key: int) -> None: + self.origin = origin + self.key = key def __repr__(self): # pylint: disable=no-member @@ -168,9 +169,8 @@ class SymbolWrapper(Wrapper[S]): __slots__ = ("name",) def __init__(self, symbol: S) -> None: - self.origin = symbol - self.name = str(symbol) - self.key = hash(self.name) + super().__init__(symbol, hash(symbol.name)) + self.name = symbol.name def __hash__(self): return self.key diff --git a/setools/policyrep/boolcond.pxi b/setools/policyrep/boolcond.pxi index 13e730be..26339fb5 100644 --- a/setools/policyrep/boolcond.pxi +++ b/setools/policyrep/boolcond.pxi @@ -333,7 +333,7 @@ cdef class ConditionalExprIterator(PolicyIterator): if self.curr.expr_type == sepol.COND_BOOL: item = Boolean.factory(self.policy, - self.policy.boolean_value_to_datum(self.curr.bool - 1)) + self.policy.boolean_value_to_datum(self.curr.boolean - 1)) else: item = ConditionalOperator.factory(self.policy, self.curr) diff --git a/setools/policyrep/selinuxpolicy.pxi b/setools/policyrep/selinuxpolicy.pxi index 236316f1..cff3b5ed 100644 --- a/setools/policyrep/selinuxpolicy.pxi +++ b/setools/policyrep/selinuxpolicy.pxi @@ -935,8 +935,7 @@ cdef class SELinuxPolicy: """ cdef: - size_t i, count - int bit + size_t bit, i, count sepol.ebitmap_node_t *node = NULL sepol.type_datum_t *tmp_type char *tmp_name diff --git a/setools/policyrep/sepol.pxd b/setools/policyrep/sepol.pxd index 36589ed1..922065e4 100644 --- a/setools/policyrep/sepol.pxd +++ b/setools/policyrep/sepol.pxd @@ -283,6 +283,14 @@ cdef extern from "": cdef extern from "": + """ + #if defined(COND_EXPR_T_RENAME_BOOL_BOOLEAN) + #define COND_EXPR_T_RENAME_BOOL_NAME boolean + #else + #define COND_EXPR_T_RENAME_BOOL_NAME bool + #endif + """ + cdef int COND_EXPR_MAXDEPTH cdef int COND_MAX_BOOLS @@ -309,7 +317,7 @@ cdef extern from "": cdef struct cond_expr: uint32_t expr_type - uint32_t bool + uint32_t boolean "COND_EXPR_T_RENAME_BOOL_NAME" cond_expr *next ctypedef cond_expr cond_expr_t diff --git a/setoolsgui/apol/analysistab.py b/setoolsgui/apol/analysistab.py index 1ed80341..bc3629ff 100644 --- a/setoolsgui/apol/analysistab.py +++ b/setoolsgui/apol/analysistab.py @@ -100,7 +100,7 @@ def clear_criteria_error(self, field, tooltip): self._check_query() def _check_query(self): - button = self.buttonBox.button(QDialogButtonBox.Apply) + button = self.buttonBox.button(QDialogButtonBox.StandardButton.Apply) enabled = not self.errors button.setEnabled(enabled) button.setToolTip("Run the analysis." if enabled else "There are errors in the tab.") diff --git a/setoolsgui/apol/boolquery.py b/setoolsgui/apol/boolquery.py index 5b0cdd8b..6116fe48 100644 --- a/setoolsgui/apol/boolquery.py +++ b/setoolsgui/apol/boolquery.py @@ -57,13 +57,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # setup indications of errors on level/range self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() # set up processing thread @@ -105,7 +105,7 @@ def setupUi(self): def get_detail(self): # .ui is set for single item selection. index = self.bools.selectedIndexes()[0] - item = self.bool_model.data(index, Qt.UserRole) + item = self.bool_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Generating detail window for {0}".format(item)) boolean_detail(self, item) @@ -187,6 +187,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/boundsquery.py b/setoolsgui/apol/boundsquery.py index 8944d1b7..5b90c2ee 100644 --- a/setoolsgui/apol/boundsquery.py +++ b/setoolsgui/apol/boundsquery.py @@ -52,13 +52,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(1, Qt.AscendingOrder) + self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder) # setup indications of errors on level/range self.errors = set() self.orig_palette = self.parent.palette() self.error_palette = self.parent.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_parent_error() self.clear_child_error() @@ -189,6 +189,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/categoryquery.py b/setoolsgui/apol/categoryquery.py index 884b4156..598f163c 100644 --- a/setoolsgui/apol/categoryquery.py +++ b/setoolsgui/apol/categoryquery.py @@ -57,13 +57,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # setup indications of errors on level/range self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() # set up processing thread @@ -105,7 +105,7 @@ def setupUi(self): def get_detail(self): # .ui is set for single item selection. index = self.cats.selectedIndexes()[0] - item = self.category_model.data(index, Qt.UserRole) + item = self.category_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Generating detail window for {0}".format(item)) category_detail(self, item) @@ -186,6 +186,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/chooseanalysis.py b/setoolsgui/apol/chooseanalysis.py index 892abdaa..155ae6d2 100644 --- a/setoolsgui/apol/chooseanalysis.py +++ b/setoolsgui/apol/chooseanalysis.py @@ -52,7 +52,7 @@ def show(self, mls): groupitem.addChild(item) self.analysisTypes.expandAll() - self.analysisTypes.sortByColumn(0, Qt.AscendingOrder) + self.analysisTypes.sortByColumn(0, Qt.SortOrder.AscendingOrder) super(ChooseAnalysis, self).show() def accept(self, item=None): diff --git a/setoolsgui/apol/commonquery.py b/setoolsgui/apol/commonquery.py index e90ec543..8fb11e87 100644 --- a/setoolsgui/apol/commonquery.py +++ b/setoolsgui/apol/commonquery.py @@ -65,13 +65,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # setup indications of errors self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() # set up processing thread @@ -116,7 +116,7 @@ def setupUi(self): def get_detail(self): # .ui is set for single item selection. index = self.commons.selectedIndexes()[0] - item = self.common_model.data(index, Qt.UserRole) + item = self.common_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Generating detail window for {0}".format(item)) common_detail(self, item) @@ -146,7 +146,7 @@ def set_name_regex(self, state): def set_perms(self): selected_perms = [] for index in self.perms.selectionModel().selectedIndexes(): - selected_perms.append(self.perms_model.data(index, Qt.UserRole)) + selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole)) self.query.perms = selected_perms @@ -212,6 +212,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/constraintquery.py b/setoolsgui/apol/constraintquery.py index cfa841b2..ee64db0c 100644 --- a/setoolsgui/apol/constraintquery.py +++ b/setoolsgui/apol/constraintquery.py @@ -84,7 +84,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_user_error() self.clear_type_error() self.clear_role_error() @@ -94,7 +94,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -173,7 +173,7 @@ def clear_all_ruletypes(self): def set_tclass(self): selected_classes = [] for index in self.tclass.selectionModel().selectedIndexes(): - selected_classes.append(self.class_model.data(index, Qt.UserRole)) + selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole)) self.query.tclass = selected_classes self.perms_model.set_classes(selected_classes) @@ -187,7 +187,7 @@ def invert_tclass_selection(self): def set_perms(self): selected_perms = [] for index in self.perms.selectionModel().selectedIndexes(): - selected_perms.append(self.perms_model.data(index, Qt.UserRole)) + selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole)) self.query.perms = selected_perms @@ -323,6 +323,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/defaultquery.py b/setoolsgui/apol/defaultquery.py index 1efa3c46..75760f7d 100644 --- a/setoolsgui/apol/defaultquery.py +++ b/setoolsgui/apol/defaultquery.py @@ -52,7 +52,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(1, Qt.AscendingOrder) + self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder) # populate class list self.class_model = SEToolsListModel(self) @@ -124,7 +124,7 @@ def clear_all_ruletypes(self): def set_tclass(self): selected_classes = [] for index in self.tclass.selectionModel().selectedIndexes(): - selected_classes.append(self.class_model.data(index, Qt.UserRole)) + selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole)) self.query.tclass = selected_classes @@ -163,10 +163,11 @@ def run(self, button): rule_types.append(mode.objectName()) self.query.ruletype = rule_types - self.query.default = self.default_value.currentData(Qt.UserRole) + self.query.default = self.default_value.currentData(Qt.ItemDataRole.UserRole) if self.default_range_value.isEnabled(): - self.query.default_range = self.default_range_value.currentData(Qt.UserRole) + self.query.default_range = self.default_range_value.currentData( + Qt.ItemDataRole.UserRole) else: self.query.default_range = None @@ -193,6 +194,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/dta.py b/setoolsgui/apol/dta.py index a78d9609..8bbed4db 100644 --- a/setoolsgui/apol/dta.py +++ b/setoolsgui/apol/dta.py @@ -62,7 +62,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_source_error() self.clear_target_error() @@ -281,7 +281,7 @@ def browser_item_selected(self, current, previous): print_transition(self.browser_details.appendPlainText, current.rules) - self.browser_details.moveCursor(QTextCursor.Start) + self.browser_details.moveCursor(QTextCursor.MoveOperation.Start) if not current.child_populated: self.busy.setLabelText("Gathering additional browser details for {0}...".format( @@ -337,7 +337,7 @@ def update_complete(self): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) if self.flows_in.isChecked() or self.flows_out.isChecked(): # move to browser tab for transitions in/out diff --git a/setoolsgui/apol/excludetypes.py b/setoolsgui/apol/excludetypes.py index bee73c58..1c4beaf8 100644 --- a/setoolsgui/apol/excludetypes.py +++ b/setoolsgui/apol/excludetypes.py @@ -40,14 +40,14 @@ def setupUi(self): if t not in self.initial_excluded_list] self.included_sort = FilterByAttributeProxy(self) self.included_sort.setSourceModel(self.included_model) - self.included_sort.sort(0, Qt.AscendingOrder) + self.included_sort.sort(0, Qt.SortOrder.AscendingOrder) self.included_types.setModel(self.included_sort) self.excluded_model = SEToolsListModel(self) self.excluded_model.item_list = self.initial_excluded_list self.excluded_sort = FilterByAttributeProxy(self) self.excluded_sort.setSourceModel(self.excluded_model) - self.excluded_sort.sort(0, Qt.AscendingOrder) + self.excluded_sort.sort(0, Qt.SortOrder.AscendingOrder) self.excluded_types.setModel(self.excluded_sort) # connect signals @@ -62,7 +62,7 @@ def include_clicked(self): selected_types = [] for index in self.excluded_types.selectionModel().selectedIndexes(): source_index = self.excluded_sort.mapToSource(index) - item = self.excluded_model.data(source_index, Qt.UserRole) + item = self.excluded_model.data(source_index, Qt.ItemDataRole.UserRole) self.included_model.append(item) selected_types.append(item) @@ -81,7 +81,7 @@ def exclude_clicked(self): selected_types = [] for index in self.included_types.selectionModel().selectedIndexes(): source_index = self.included_sort.mapToSource(index) - item = self.included_model.data(source_index, Qt.UserRole) + item = self.included_model.data(source_index, Qt.ItemDataRole.UserRole) self.excluded_model.append(item) selected_types.append(item) @@ -95,7 +95,7 @@ def exclude_clicked(self): def set_attr_filter(self, row): index = self.attr_model.index(row) - attr = self.attr_model.data(index, Qt.UserRole) + attr = self.attr_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Attribute set to {0!r}".format(attr)) self.included_sort.attr = attr self.excluded_sort.attr = attr @@ -126,7 +126,7 @@ def filterAcceptsRow(self, row, parent): if self.attr: source = self.sourceModel() index = source.index(row) - item = source.data(index, Qt.UserRole) + item = source.data(index, Qt.ItemDataRole.UserRole) if item not in self.attr: return False diff --git a/setoolsgui/apol/fsusequery.py b/setoolsgui/apol/fsusequery.py index 9bb192b3..4e7567f4 100644 --- a/setoolsgui/apol/fsusequery.py +++ b/setoolsgui/apol/fsusequery.py @@ -74,7 +74,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_fs_error() self.clear_user_error() self.clear_type_error() @@ -86,7 +86,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(1, Qt.AscendingOrder) + self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -312,6 +312,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/genfsconquery.py b/setoolsgui/apol/genfsconquery.py index 22112a8f..33dbed78 100644 --- a/setoolsgui/apol/genfsconquery.py +++ b/setoolsgui/apol/genfsconquery.py @@ -74,7 +74,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_fs_error() self.clear_path_error() self.clear_user_error() @@ -87,7 +87,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -312,6 +312,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/ibendportconquery.py b/setoolsgui/apol/ibendportconquery.py index 6db99c2b..18252dd2 100644 --- a/setoolsgui/apol/ibendportconquery.py +++ b/setoolsgui/apol/ibendportconquery.py @@ -74,7 +74,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() self.clear_port_error() self.clear_user_error() @@ -87,7 +87,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -304,6 +304,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/ibpkeyconquery.py b/setoolsgui/apol/ibpkeyconquery.py index 3efd3421..b7a78bf9 100644 --- a/setoolsgui/apol/ibpkeyconquery.py +++ b/setoolsgui/apol/ibpkeyconquery.py @@ -74,7 +74,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_subnet_prefix_error() self.clear_pkeys_error() self.clear_user_error() @@ -87,7 +87,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -317,6 +317,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/infoflow.py b/setoolsgui/apol/infoflow.py index fb9b4099..526f3074 100644 --- a/setoolsgui/apol/infoflow.py +++ b/setoolsgui/apol/infoflow.py @@ -75,7 +75,7 @@ def setupUi(self): # set up error message for missing perm map self.error_msg = QMessageBox(self) - self.error_msg.setStandardButtons(QMessageBox.Ok) + self.error_msg.setStandardButtons(QMessageBox.StandardButton.Ok) # set up perm map editor self.permmap_editor = PermissionMapEditor(self, False) @@ -93,7 +93,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_source_error() self.clear_target_error() @@ -325,7 +325,7 @@ def browser_item_selected(self, current, previous): for rule in current.rules: self.browser_details.appendPlainText(rule) - self.browser_details.moveCursor(QTextCursor.Start) + self.browser_details.moveCursor(QTextCursor.MoveOperation.Start) if not current.child_populated: self.busy.setLabelText("Gathering additional browser details for {0}...".format( @@ -390,7 +390,7 @@ def update_complete(self): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) if self.flows_in.isChecked() or self.flows_out.isChecked(): # move to browser tab for flows in/out diff --git a/setoolsgui/apol/initsidquery.py b/setoolsgui/apol/initsidquery.py index b31c9986..d01f8713 100644 --- a/setoolsgui/apol/initsidquery.py +++ b/setoolsgui/apol/initsidquery.py @@ -74,7 +74,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() self.clear_user_error() self.clear_type_error() @@ -86,7 +86,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -287,6 +287,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/mainwindow.py b/setoolsgui/apol/mainwindow.py index 3cdb11d3..dcbfb759 100644 --- a/setoolsgui/apol/mainwindow.py +++ b/setoolsgui/apol/mainwindow.py @@ -60,20 +60,20 @@ def setupUi(self): # set up error message dialog self.error_msg = QMessageBox(self) - self.error_msg.setStandardButtons(QMessageBox.Ok) + self.error_msg.setStandardButtons(QMessageBox.StandardButton.Ok) # set up permission map editor self.permmap_editor = PermissionMapEditor(self, True) # set up tab name editor self.tab_editor = QLineEdit(self.AnalysisTabs) - self.tab_editor.setWindowFlags(Qt.Popup) + self.tab_editor.setWindowFlags(Qt.WindowType.Popup) # configure tab bar context menu tabBar = self.AnalysisTabs.tabBar() tabBar.addAction(self.rename_tab_action) tabBar.addAction(self.close_tab_action) - tabBar.setContextMenuPolicy(Qt.ActionsContextMenu) + tabBar.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu) # capture INFO and higher Python messages from setools lib for status bar handler = LogHandlerToSignal() @@ -127,9 +127,9 @@ def select_policy(self): reply = QMessageBox.question( self, "Continue?", "Loading a policy will close all existing analyses. Continue?", - QMessageBox.Yes | QMessageBox.No) + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) - if reply == QMessageBox.No: + if reply == QMessageBox.StandardButton.No: return filename = QFileDialog.getOpenFileName(self, "Open policy file", ".", @@ -163,9 +163,9 @@ def close_policy(self): reply = QMessageBox.question( self, "Continue?", "Closing a policy will close all existing analyses. Continue?", - QMessageBox.Yes | QMessageBox.No) + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) - if reply == QMessageBox.No: + if reply == QMessageBox.StandardButton.No: return self.AnalysisTabs.clear() @@ -245,7 +245,7 @@ def create_new_analysis(self, tabtitle, tabclass): counted_name = "{0}: {1}".format(self.tab_counter, tabtitle) newanalysis = tabclass(self, self._policy, self._permmap) - newanalysis.setAttribute(Qt.WA_DeleteOnClose) + newanalysis.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) newanalysis.setObjectName(counted_name) index = self.AnalysisTabs.addTab(newanalysis, counted_name) @@ -444,9 +444,9 @@ def load_workspace(self): reply = QMessageBox.question( self, "Continue?", "Loading a workspace will close all existing analyses. Continue?", - QMessageBox.Yes | QMessageBox.No) + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) - if reply == QMessageBox.No: + if reply == QMessageBox.StandardButton.No: return # 2. try to load the workspace file, if we fail, bail @@ -633,7 +633,7 @@ def about_apol(self): def apol_help(self): """Open the main help window.""" - if self.help_process.state() != QProcess.NotRunning: + if self.help_process.state() != QProcess.ProcessState.NotRunning: return distro = pkg_resources.get_distribution("setools") @@ -648,7 +648,7 @@ def apol_help(self): @pyqtSlot(QProcess.ProcessError) def help_failed(self, error): """Starting assistant failed.""" - if error != QProcess.FailedToStart: + if error != QProcess.ProcessError.FailedToStart: return self.log.error("Failed to start Qt assistant {}.".format(self.config.assistant)) @@ -669,9 +669,9 @@ def _find_assistant(self): "This is typically in the assistant or qt5-assistant package. " "Choose location of Qt Assistant executable?".format( self.config.assistant), - QMessageBox.Yes | QMessageBox.No) + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) - if reply == QMessageBox.No: + if reply == QMessageBox.StandardButton.No: return filename = QFileDialog.getOpenFileName(self, "Location of qt-assistant executable", @@ -689,12 +689,12 @@ def _find_assistant(self): @pyqtSlot(str) def set_help(self, location): """Set the help window to the specified document.""" - if self.help_process.state() == QProcess.NotStarted: + if self.help_process.state() == QProcess.ProcessState.NotRunning: self.apol_help() if not self.help_process.waitForStarted(): self.log.warning("Timed out waiting for Qt assistant to start.") return - elif self.help_process.state() == QProcess.Starting: + elif self.help_process.state() == QProcess.ProcessState.Starting: if not self.help_process.waitForStarted(): self.log.warning("Timed out waiting for Qt assistant to start.") return diff --git a/setoolsgui/apol/mlsrulequery.py b/setoolsgui/apol/mlsrulequery.py index ba2be459..bb554ade 100644 --- a/setoolsgui/apol/mlsrulequery.py +++ b/setoolsgui/apol/mlsrulequery.py @@ -61,7 +61,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_source_error() self.clear_target_error() self.clear_default_error() @@ -76,7 +76,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(1, Qt.AscendingOrder) + self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -181,7 +181,7 @@ def set_target_regex(self, state): def set_tclass(self): selected_classes = [] for index in self.tclass.selectionModel().selectedIndexes(): - selected_classes.append(self.class_model.data(index, Qt.UserRole)) + selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole)) self.query.tclass = selected_classes @@ -264,6 +264,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/netifconquery.py b/setoolsgui/apol/netifconquery.py index ca2405f7..4cf3de1a 100644 --- a/setoolsgui/apol/netifconquery.py +++ b/setoolsgui/apol/netifconquery.py @@ -74,7 +74,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() self.clear_user_error() self.clear_type_error() @@ -86,7 +86,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -287,6 +287,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/nodeconquery.py b/setoolsgui/apol/nodeconquery.py index 320b0d61..81a33a79 100644 --- a/setoolsgui/apol/nodeconquery.py +++ b/setoolsgui/apol/nodeconquery.py @@ -80,7 +80,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_network_error() self.clear_user_error() self.clear_type_error() @@ -92,7 +92,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -263,7 +263,7 @@ def load(self, settings): def run(self, button): # right now there is only one button. self.query.network_overlap = self.network_overlap.isChecked() - self.query.ip_version = self.ip_version.currentData(Qt.UserRole) + self.query.ip_version = self.ip_version.currentData(Qt.ItemDataRole.UserRole) self.query.range_overlap = self.range_overlap.isChecked() self.query.range_subset = self.range_subset.isChecked() self.query.range_superset = self.range_superset.isChecked() @@ -291,6 +291,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/objclassquery.py b/setoolsgui/apol/objclassquery.py index 9744a187..23c8188e 100644 --- a/setoolsgui/apol/objclassquery.py +++ b/setoolsgui/apol/objclassquery.py @@ -66,13 +66,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # setup indications of errors on level/range self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() # set up processing thread @@ -117,7 +117,7 @@ def setupUi(self): def get_detail(self): # .ui is set for single item selection. index = self.classes.selectedIndexes()[0] - item = self.class_model.data(index, Qt.UserRole) + item = self.class_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Generating detail window for {0}".format(item)) class_detail(self, item) @@ -146,7 +146,7 @@ def set_name_regex(self, state): # def set_common(self): for index in self.common.selectionModel().selectedIndexes(): - self.query.common = self.common_model.data(index, Qt.UserRole) + self.query.common = self.common_model.data(index, Qt.ItemDataRole.UserRole) break else: self.query.common = None @@ -157,7 +157,7 @@ def set_common(self): def set_perms(self): selected_perms = [] for index in self.perms.selectionModel().selectedIndexes(): - selected_perms.append(self.perms_model.data(index, Qt.UserRole)) + selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole)) self.query.perms = selected_perms @@ -224,6 +224,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/permmapedit.py b/setoolsgui/apol/permmapedit.py index 97482b30..d1e0b01c 100644 --- a/setoolsgui/apol/permmapedit.py +++ b/setoolsgui/apol/permmapedit.py @@ -86,7 +86,7 @@ def accept(self): def class_selected(self): # the .ui is set to 1 selection for index in self.classes.selectionModel().selectedIndexes(): - class_name = self.class_model.data(index, Qt.DisplayRole) + class_name = self.class_model.data(index, Qt.ItemDataRole.DisplayRole) self.log.debug("Setting class to {0}".format(class_name)) @@ -99,15 +99,15 @@ def class_selected(self): for perm in sorted(self.perm_map.perms(class_name)): # create permission mapping mapping = PermissionMapping(self, perm, self.edit) - mapping.setAttribute(Qt.WA_DeleteOnClose) + mapping.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) self.class_toggle.connect(mapping.enabled.setChecked) self.perm_mappings.addWidget(mapping) self.widgets.append(mapping) # add horizonal line line = QFrame(self) - line.setFrameShape(QFrame.HLine) - line.setFrameShadow(QFrame.Sunken) + line.setFrameShape(QFrame.Shape.HLine) + line.setFrameShadow(QFrame.Shadow.Sunken) self.perm_mappings.addWidget(line) self.widgets.append(line) @@ -179,8 +179,8 @@ def setupUi(self): # setup color palettes for direction self.orig_palette = self.direction.palette() self.error_palette = self.direction.palette() - self.error_palette.setColor(QPalette.Button, Qt.red) - self.error_palette.setColor(QPalette.ButtonText, Qt.white) + self.error_palette.setColor(QPalette.ColorRole.Button, Qt.GlobalColor.red) + self.error_palette.setColor(QPalette.ColorRole.ButtonText, Qt.GlobalColor.white) # setup direction self.direction.insertItems(0, index_to_word) diff --git a/setoolsgui/apol/portconquery.py b/setoolsgui/apol/portconquery.py index 50d054f8..de0a1656 100644 --- a/setoolsgui/apol/portconquery.py +++ b/setoolsgui/apol/portconquery.py @@ -75,7 +75,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_ports_error() self.clear_user_error() self.clear_type_error() @@ -92,7 +92,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -280,7 +280,7 @@ def run(self, button): self.query.ports_overlap = self.ports_overlap.isChecked() self.query.ports_subset = self.ports_subset.isChecked() self.query.ports_superset = self.ports_superset.isChecked() - self.query.protocol = self.protocol.currentData(Qt.UserRole) + self.query.protocol = self.protocol.currentData(Qt.ItemDataRole.UserRole) self.query.range_overlap = self.range_overlap.isChecked() self.query.range_subset = self.range_subset.isChecked() self.query.range_superset = self.range_superset.isChecked() @@ -308,6 +308,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/rbacrulequery.py b/setoolsgui/apol/rbacrulequery.py index 0ce4bb9a..4749d324 100644 --- a/setoolsgui/apol/rbacrulequery.py +++ b/setoolsgui/apol/rbacrulequery.py @@ -71,7 +71,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_source_error() self.clear_target_error() self.clear_default_error() @@ -86,7 +86,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -194,7 +194,7 @@ def set_target_regex(self, state): def set_tclass(self): selected_classes = [] for index in self.tclass.selectionModel().selectedIndexes(): - selected_classes.append(self.class_model.data(index, Qt.UserRole)) + selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole)) self.query.tclass = selected_classes @@ -292,6 +292,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/rolequery.py b/setoolsgui/apol/rolequery.py index 29983a59..e75614d9 100644 --- a/setoolsgui/apol/rolequery.py +++ b/setoolsgui/apol/rolequery.py @@ -62,13 +62,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # setup indications of errors on level/range self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() # set up processing thread @@ -112,7 +112,7 @@ def setupUi(self): def get_detail(self): # .ui is set for single item selection. index = self.roles.selectedIndexes()[0] - item = self.role_model.data(index, Qt.UserRole) + item = self.role_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Generating detail window for {0}".format(item)) role_detail(self, item) @@ -142,7 +142,7 @@ def set_name_regex(self, state): def set_types(self): selected_types = [] for index in self.types.selectionModel().selectedIndexes(): - selected_types.append(self.type_model.data(index, Qt.UserRole)) + selected_types.append(self.type_model.data(index, Qt.ItemDataRole.UserRole)) self.query.types = selected_types @@ -209,6 +209,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/sensitivityquery.py b/setoolsgui/apol/sensitivityquery.py index d5bcbec5..c8a27891 100644 --- a/setoolsgui/apol/sensitivityquery.py +++ b/setoolsgui/apol/sensitivityquery.py @@ -57,13 +57,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # setup indications of errors on level/range self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() # set up processing thread @@ -105,7 +105,7 @@ def setupUi(self): def get_detail(self): # .ui is set for single item selection. index = self.sens.selectedIndexes()[0] - item = self.sensitivity_model.data(index, Qt.UserRole) + item = self.sensitivity_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Generating detail window for {0}".format(item)) sensitivity_detail(self, item) @@ -186,6 +186,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/terulequery.py b/setoolsgui/apol/terulequery.py index 30647105..7c99469e 100644 --- a/setoolsgui/apol/terulequery.py +++ b/setoolsgui/apol/terulequery.py @@ -69,7 +69,7 @@ def setupUi(self): self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_source_error() self.clear_target_error() self.clear_default_error() @@ -94,7 +94,7 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # set up processing thread self.thread = QThread() @@ -221,7 +221,7 @@ def set_target_regex(self, state): def set_tclass(self): selected_classes = [] for index in self.tclass.selectionModel().selectedIndexes(): - selected_classes.append(self.class_model.data(index, Qt.UserRole)) + selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole)) self.query.tclass = selected_classes self.perms_model.set_classes(selected_classes) @@ -236,7 +236,7 @@ def invert_tclass_selection(self): def set_perms(self): selected_perms = [] for index in self.perms.selectionModel().selectedIndexes(): - selected_perms.append(self.perms_model.data(index, Qt.UserRole)) + selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole)) self.query.perms = selected_perms @@ -302,7 +302,7 @@ def set_default_regex(self, state): def set_bools(self): selected_bools = [] for index in self.bool_criteria.selectionModel().selectedIndexes(): - selected_bools.append(self.bool_model.data(index, Qt.UserRole)) + selected_bools.append(self.bool_model.data(index, Qt.ItemDataRole.UserRole)) self.query.boolean = selected_bools @@ -407,9 +407,9 @@ def run(self, button): reply = QMessageBox.question( self, "Continue?", "This is a broad query, estimated to return {0} results. Continue?". - format(max_results), QMessageBox.Yes | QMessageBox.No) + format(max_results), QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) - if reply == QMessageBox.No: + if reply == QMessageBox.StandardButton.No: return # start processing @@ -440,6 +440,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/typeattrquery.py b/setoolsgui/apol/typeattrquery.py index 14a4141d..67a087a7 100644 --- a/setoolsgui/apol/typeattrquery.py +++ b/setoolsgui/apol/typeattrquery.py @@ -62,13 +62,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # setup indications of errors on level/range self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() # set up processing thread @@ -112,7 +112,7 @@ def setupUi(self): def get_detail(self): # .ui is set for single item selection. index = self.attrs.selectedIndexes()[0] - item = self.attr_model.data(index, Qt.UserRole) + item = self.attr_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Generating detail window for {0}".format(item)) typeattr_detail(self, item) @@ -142,7 +142,7 @@ def set_name_regex(self, state): def set_types(self): selected_types = [] for index in self.types.selectionModel().selectedIndexes(): - selected_types.append(self.type_model.data(index, Qt.UserRole)) + selected_types.append(self.type_model.data(index, Qt.ItemDataRole.UserRole)) self.query.types = selected_types @@ -209,6 +209,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/typequery.py b/setoolsgui/apol/typequery.py index 2e261ccd..a22e3547 100644 --- a/setoolsgui/apol/typequery.py +++ b/setoolsgui/apol/typequery.py @@ -62,13 +62,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # setup indications of errors on level/range self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() # set up processing thread @@ -112,7 +112,7 @@ def setupUi(self): def get_detail(self): # .ui is set for single item selection. index = self.types.selectedIndexes()[0] - item = self.type_model.data(index, Qt.UserRole) + item = self.type_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Generating detail window for {0}".format(item)) type_detail(self, item) @@ -142,7 +142,7 @@ def set_name_regex(self, state): def set_attrs(self): selected_attrs = [] for index in self.attrs.selectionModel().selectedIndexes(): - selected_attrs.append(self.attr_model.data(index, Qt.UserRole)) + selected_attrs.append(self.attr_model.data(index, Qt.ItemDataRole.UserRole)) self.query.attrs = selected_attrs @@ -213,6 +213,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/userquery.py b/setoolsgui/apol/userquery.py index c325888d..19ffb03c 100644 --- a/setoolsgui/apol/userquery.py +++ b/setoolsgui/apol/userquery.py @@ -62,13 +62,13 @@ def setupUi(self): self.sort_proxy = QSortFilterProxyModel(self) self.sort_proxy.setSourceModel(self.table_results_model) self.table_results.setModel(self.sort_proxy) - self.table_results.sortByColumn(0, Qt.AscendingOrder) + self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder) # setup indications of errors on level/range self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() - self.error_palette.setColor(QPalette.Base, Qt.red) + self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red) self.clear_name_error() if self.policy.mls: @@ -135,7 +135,7 @@ def setupUi(self): def get_detail(self): # .ui is set for single item selection. index = self.users.selectedIndexes()[0] - item = self.user_model.data(index, Qt.UserRole) + item = self.user_model.data(index, Qt.ItemDataRole.UserRole) self.log.debug("Generating detail window for {0}".format(item)) user_detail(self, item) @@ -165,7 +165,7 @@ def set_name_regex(self, state): def set_roles(self): selected_roles = [] for index in self.roles.selectionModel().selectedIndexes(): - selected_roles.append(self.role_model.data(index, Qt.UserRole)) + selected_roles.append(self.role_model.data(index, Qt.ItemDataRole.UserRole)) self.query.roles = selected_roles @@ -262,6 +262,6 @@ def update_complete(self, count): if not self.busy.wasCanceled(): self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive") self.busy.repaint() - self.raw_results.moveCursor(QTextCursor.Start) + self.raw_results.moveCursor(QTextCursor.MoveOperation.Start) self.busy.reset() diff --git a/setoolsgui/apol/workspace.py b/setoolsgui/apol/workspace.py index 0f8ec82c..2b422922 100644 --- a/setoolsgui/apol/workspace.py +++ b/setoolsgui/apol/workspace.py @@ -141,7 +141,7 @@ def save_listviews(tab, settings, listviews): selections = [] for index in listview.selectedIndexes(): - item = datamodel.data(index, Qt.DisplayRole) + item = datamodel.data(index, Qt.ItemDataRole.DisplayRole) selections.append(item) settings[entry] = selections @@ -181,10 +181,10 @@ def load_listviews(tab, settings, listviews): for row in range(datamodel.rowCount()): index = datamodel.createIndex(row, 0) - item = datamodel.data(index, Qt.DisplayRole) + item = datamodel.data(index, Qt.ItemDataRole.DisplayRole) if item in selections: - selectionmodel.select(index, QItemSelectionModel.Select) + selectionmodel.select(index, QItemSelectionModel.SelectionFlag.Select) def save_comboboxes(tab, settings, comboboxes): @@ -199,7 +199,7 @@ def save_comboboxes(tab, settings, comboboxes): for entry in comboboxes: combobox = getattr(tab, entry) - settings[entry] = combobox.currentData(Qt.DisplayRole) + settings[entry] = combobox.currentData(Qt.ItemDataRole.DisplayRole) def load_comboboxes(tab, settings, comboboxes): diff --git a/setoolsgui/boolmodel.py b/setoolsgui/boolmodel.py index 0d698c92..c331fdd5 100644 --- a/setoolsgui/boolmodel.py +++ b/setoolsgui/boolmodel.py @@ -38,12 +38,12 @@ def data(self, index, role): col = index.column() boolean = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return boolean.name elif col == 1: return str(boolean.state) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: # get the whole rule for boolean boolean return boolean diff --git a/setoolsgui/boundsmodel.py b/setoolsgui/boundsmodel.py index c84f612a..c7ed1e7c 100644 --- a/setoolsgui/boundsmodel.py +++ b/setoolsgui/boundsmodel.py @@ -20,7 +20,7 @@ def data(self, index, role): col = index.column() item = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return item.ruletype.name elif col == 1: @@ -28,5 +28,5 @@ def data(self, index, role): elif col == 2: return item.child.name - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return item diff --git a/setoolsgui/commonmodel.py b/setoolsgui/commonmodel.py index a6f6fed5..2ceb57f4 100644 --- a/setoolsgui/commonmodel.py +++ b/setoolsgui/commonmodel.py @@ -42,11 +42,11 @@ def data(self, index, role): col = index.column() item = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return item.name elif col == 1: return ", ".join(sorted(item.perms)) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return item diff --git a/setoolsgui/constraintmodel.py b/setoolsgui/constraintmodel.py index 122dff0b..d295f28f 100644 --- a/setoolsgui/constraintmodel.py +++ b/setoolsgui/constraintmodel.py @@ -21,7 +21,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return rule.ruletype.name elif col == 1: @@ -34,5 +34,5 @@ def data(self, index, role): elif col == 3: return str(rule.expression) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/defaultmodel.py b/setoolsgui/defaultmodel.py index b9a6a58e..3a699c49 100644 --- a/setoolsgui/defaultmodel.py +++ b/setoolsgui/defaultmodel.py @@ -22,7 +22,7 @@ def data(self, index, role): col = index.column() item = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return item.ruletype.name elif col == 1: @@ -33,5 +33,5 @@ def data(self, index, role): with suppress(AttributeError): return item.default_range.name - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return item diff --git a/setoolsgui/details.py b/setoolsgui/details.py index 4eb70066..8d4882cd 100644 --- a/setoolsgui/details.py +++ b/setoolsgui/details.py @@ -37,15 +37,15 @@ def title(self, text): self.setWindowTitle(text) def append(self, text): - self.contents.setFontWeight(QFont.Normal) + self.contents.setFontWeight(QFont.Weight.Normal) self.contents.setFontPointSize(9) self.contents.append(text) def append_header(self, text): - self.contents.setFontWeight(QFont.Black) + self.contents.setFontWeight(QFont.Weight.Black) self.contents.setFontPointSize(11) self.contents.append(text) def show(self): - self.contents.moveCursor(QTextCursor.Start) + self.contents.moveCursor(QTextCursor.MoveOperation.Start) super(DetailsPopup, self).show() diff --git a/setoolsgui/fsusemodel.py b/setoolsgui/fsusemodel.py index 2b3a3f40..bc100784 100644 --- a/setoolsgui/fsusemodel.py +++ b/setoolsgui/fsusemodel.py @@ -20,7 +20,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return rule.ruletype.name elif col == 1: @@ -28,5 +28,5 @@ def data(self, index, role): elif col == 2: return str(rule.context) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/genfsconmodel.py b/setoolsgui/genfsconmodel.py index 6fc46408..1e50d929 100644 --- a/setoolsgui/genfsconmodel.py +++ b/setoolsgui/genfsconmodel.py @@ -32,7 +32,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return rule.fs elif col == 1: @@ -42,5 +42,5 @@ def data(self, index, role): elif col == 3: return str(rule.context) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/ibendportconmodel.py b/setoolsgui/ibendportconmodel.py index 199932d3..37b7a8d7 100644 --- a/setoolsgui/ibendportconmodel.py +++ b/setoolsgui/ibendportconmodel.py @@ -20,7 +20,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return rule.name elif col == 1: @@ -28,5 +28,5 @@ def data(self, index, role): elif col == 2: return str(rule.context) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/ibpkeyconmodel.py b/setoolsgui/ibpkeyconmodel.py index f3cd9520..16042550 100644 --- a/setoolsgui/ibpkeyconmodel.py +++ b/setoolsgui/ibpkeyconmodel.py @@ -20,7 +20,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return str(rule.subnet_prefix) elif col == 1: @@ -32,5 +32,5 @@ def data(self, index, role): elif col == 2: return str(rule.context) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/initsidmodel.py b/setoolsgui/initsidmodel.py index 1155a50f..9ffb4080 100644 --- a/setoolsgui/initsidmodel.py +++ b/setoolsgui/initsidmodel.py @@ -20,11 +20,11 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return rule.name elif col == 1: return str(rule.context) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/listview.py b/setoolsgui/listview.py index a4beda50..e803975c 100644 --- a/setoolsgui/listview.py +++ b/setoolsgui/listview.py @@ -34,14 +34,14 @@ def invert(self): for row in range(model.rowCount()): index = model.createIndex(row, 0) - selection_model.select(index, QItemSelectionModel.Toggle) + selection_model.select(index, QItemSelectionModel.SelectionFlag.Toggle) - def selection(self, qt_role=Qt.UserRole): + def selection(self, qt_role=Qt.ItemDataRole.UserRole): """ Generator which returns the selection. Parameter: - qt_role The Qt model role. Default is Qt.UserRole. + qt_role The Qt model role. Default is Qt.ItemDataRole.UserRole. Yield: tuple(row, data) row The row number of the selection. diff --git a/setoolsgui/mlsmodel.py b/setoolsgui/mlsmodel.py index 8dfb2806..147378ef 100644 --- a/setoolsgui/mlsmodel.py +++ b/setoolsgui/mlsmodel.py @@ -63,11 +63,11 @@ def data(self, index, role): col = index.column() item = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return item.name elif col == 1: return ", ".join(sorted(a for a in item.aliases())) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return item diff --git a/setoolsgui/mlsrulemodel.py b/setoolsgui/mlsrulemodel.py index 4fa4f186..54ad4c21 100644 --- a/setoolsgui/mlsrulemodel.py +++ b/setoolsgui/mlsrulemodel.py @@ -20,7 +20,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return rule.ruletype.name elif col == 1: @@ -32,5 +32,5 @@ def data(self, index, role): elif col == 4: return str(rule.default) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/models.py b/setoolsgui/models.py index fc7bf3df..dd864e93 100644 --- a/setoolsgui/models.py +++ b/setoolsgui/models.py @@ -19,7 +19,7 @@ def invert_list_selection(selection_model): rowcount = model.rowCount() for row in range(rowcount): index = model.createIndex(row, 0) - selection_model.select(index, QItemSelectionModel.Toggle) + selection_model.select(index, QItemSelectionModel.SelectionFlag.Toggle) class SEToolsListModel(QAbstractListModel): @@ -27,8 +27,8 @@ class SEToolsListModel(QAbstractListModel): """ The purpose of this model is to have the objects return their string representations - for Qt.DisplayRole and return the object - for Qt.UserRole. + for Qt.ItemDataRole.DisplayRole and return the object + for Qt.ItemDataRole.UserRole. Some Python list-like functions are provided for altering the model: append and remove @@ -81,9 +81,9 @@ def data(self, index, role): row = index.row() item = self.item_list[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: return str(item) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return item @@ -133,7 +133,7 @@ def __init__(self, parent): self.resultlist = [] def headerData(self, section, orientation, role): - if role == Qt.DisplayRole and orientation == Qt.Horizontal: + if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal: return self.headers[section] def rowCount(self, parent=QModelIndex()): diff --git a/setoolsgui/netifconmodel.py b/setoolsgui/netifconmodel.py index 3d2e4b8b..54659203 100644 --- a/setoolsgui/netifconmodel.py +++ b/setoolsgui/netifconmodel.py @@ -20,7 +20,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return rule.netif elif col == 1: @@ -28,5 +28,5 @@ def data(self, index, role): elif col == 2: return str(rule.packet) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/nodeconmodel.py b/setoolsgui/nodeconmodel.py index ec4d66e9..f8055fca 100644 --- a/setoolsgui/nodeconmodel.py +++ b/setoolsgui/nodeconmodel.py @@ -20,11 +20,11 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return str(rule.network.with_netmask) elif col == 1: return str(rule.context) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/objclassmodel.py b/setoolsgui/objclassmodel.py index 9823b73b..ff1641f8 100644 --- a/setoolsgui/objclassmodel.py +++ b/setoolsgui/objclassmodel.py @@ -58,7 +58,7 @@ def data(self, index, role): col = index.column() item = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return item.name elif col == 1: @@ -69,5 +69,5 @@ def data(self, index, role): return ", ".join(sorted(chain(com_perms, item.perms))) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return item diff --git a/setoolsgui/portconmodel.py b/setoolsgui/portconmodel.py index 39d2c72e..1c3de449 100644 --- a/setoolsgui/portconmodel.py +++ b/setoolsgui/portconmodel.py @@ -20,7 +20,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: low, high = rule.ports if low == high: @@ -32,5 +32,5 @@ def data(self, index, role): elif col == 2: return str(rule.context) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/rbacrulemodel.py b/setoolsgui/rbacrulemodel.py index d8df9409..84d2ff09 100644 --- a/setoolsgui/rbacrulemodel.py +++ b/setoolsgui/rbacrulemodel.py @@ -21,7 +21,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return rule.ruletype.name elif col == 1: @@ -41,5 +41,5 @@ def data(self, index, role): except RuleUseError: return None - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/rolemodel.py b/setoolsgui/rolemodel.py index 004f4e76..2dd7fe64 100644 --- a/setoolsgui/rolemodel.py +++ b/setoolsgui/rolemodel.py @@ -47,11 +47,11 @@ def data(self, index, role): col = index.column() item = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return item.name elif col == 1: return ", ".join(sorted(t.name for t in item.types())) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: # get the whole object return item diff --git a/setoolsgui/tableview.py b/setoolsgui/tableview.py index 9726cb05..af764256 100644 --- a/setoolsgui/tableview.py +++ b/setoolsgui/tableview.py @@ -45,7 +45,7 @@ def copy(self): elif prev_col is not None and current_col != prev_col: selected_text.append('\t') - selected_text.append(datamodel.data(index, Qt.DisplayRole)) + selected_text.append(datamodel.data(index, Qt.ItemDataRole.DisplayRole)) prev_row = current_row prev_col = current_col @@ -76,7 +76,9 @@ def save_csv(self, filename): # write headers csv_row = [] for col in range(col_count): - csv_row.append(datamodel.headerData(col, Qt.Horizontal, Qt.DisplayRole)) + csv_row.append(datamodel.headerData(col, + Qt.Orientation.Horizontal, + Qt.ItemDataRole.DisplayRole)) writer.writerow(csv_row) @@ -86,6 +88,6 @@ def save_csv(self, filename): for col in range(col_count): index = datamodel.index(row, col) - csv_row.append(datamodel.data(index, Qt.DisplayRole)) + csv_row.append(datamodel.data(index, Qt.ItemDataRole.DisplayRole)) writer.writerow(csv_row) diff --git a/setoolsgui/terulemodel.py b/setoolsgui/terulemodel.py index 4d51ac8e..53b61a06 100644 --- a/setoolsgui/terulemodel.py +++ b/setoolsgui/terulemodel.py @@ -22,7 +22,7 @@ def data(self, index, role): col = index.column() rule = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return rule.ruletype.name elif col == 1: @@ -50,5 +50,5 @@ def data(self, index, role): except RuleNotConditional: return None - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return rule diff --git a/setoolsgui/typeattrmodel.py b/setoolsgui/typeattrmodel.py index 1a752fcd..0b7c7ffe 100644 --- a/setoolsgui/typeattrmodel.py +++ b/setoolsgui/typeattrmodel.py @@ -44,11 +44,11 @@ def data(self, index, role): col = index.column() item = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return item.name elif col == 1: return ", ".join(sorted(t.name for t in item.expand())) - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return item diff --git a/setoolsgui/typemodel.py b/setoolsgui/typemodel.py index 841cc42a..037996b9 100644 --- a/setoolsgui/typemodel.py +++ b/setoolsgui/typemodel.py @@ -50,7 +50,7 @@ def data(self, index, role): col = index.column() item = self.resultlist[row] - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: if col == 0: return item.name elif col == 1: @@ -60,5 +60,5 @@ def data(self, index, role): elif col == 3 and item.ispermissive: return "Permissive" - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return item diff --git a/setoolsgui/usermodel.py b/setoolsgui/usermodel.py index d0a4b0ed..d5aca7bc 100644 --- a/setoolsgui/usermodel.py +++ b/setoolsgui/usermodel.py @@ -56,7 +56,7 @@ def columnCount(self, parent=QModelIndex()): def data(self, index, role): if self.resultlist and index.isValid(): - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: row = index.row() col = index.column() user = self.resultlist[row] @@ -76,5 +76,5 @@ def data(self, index, role): except MLSDisabled: return None - elif role == Qt.UserRole: + elif role == Qt.ItemDataRole.UserRole: return user diff --git a/setup.py b/setup.py index 3cfd9271..5584e551 100644 --- a/setup.py +++ b/setup.py @@ -133,7 +133,7 @@ def run(self): installed_data.append((join('share/man', lang, 'man1'), glob.glob(join("man", lang, "*.1")))) setup(name='setools', - version='4.4.3', + version='4.4.4', description='SELinux policy analysis tools.', author='Chris PeBenito', author_email='pebenito@ieee.org', diff --git a/tox.ini b/tox.ini index a668bb3d..e7148d36 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -minversion = 1.4 +minversion = 2.4 envlist = python3, pep8, lint, mypy [pycodestyle] @@ -51,10 +51,11 @@ commands = {envpython} -m pip install --use-pep517 . [testenv] passenv = USERSPACE_SRC deps = networkx>=2.0 - cython>=0.27 - pytest - python38: cython>=0.29.14 - python39: networkx>=2.6 - python39: cython>=0.29.14 + cython>=0.29.14 + pytest>=6.0 + python3.6: dataclasses + python3.9: networkx>=2.6 + python3.10: networkx>=2.6 + python3.11: networkx>=2.6 commands_pre = {envpython} setup.py build_ext -i commands = pytest tests