Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 11, 2023
1 parent 39db90d commit 1ba533a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
17 changes: 9 additions & 8 deletions koordinates/gui/datasets_browser_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@
QLabel,
QToolButton,
QVBoxLayout,
QSizePolicy,
QWidget
)
from qgis.gui import QgsScrollArea

from .response_table_layout import ResponsiveTableWidget
from ..api import (
KoordinatesClient,
PAGE_SIZE,
DataBrowserQuery,
ExplorePanel
DataBrowserQuery
)

pluginPath = os.path.split(os.path.dirname(__file__))[0]
Expand Down Expand Up @@ -96,7 +93,8 @@ def _fetch_records(self,
query: Optional[DataBrowserQuery] = None,
context: Optional[str] = None,
page: int = 1):
if self._current_reply is not None and not sip.isdeleted(self._current_reply):
if self._current_reply is not None and not sip.isdeleted(
self._current_reply):
self._current_reply.abort()
self._current_reply = None

Expand All @@ -110,7 +108,8 @@ def _fetch_records(self,
context=self._current_context,
page=page
)
self._current_reply.finished.connect(partial(self._reply_finished, self._current_reply))
self._current_reply.finished.connect(
partial(self._reply_finished, self._current_reply))
self.setCursor(Qt.WaitCursor)

def _reply_finished(self, reply: QNetworkReply):
Expand All @@ -133,11 +132,13 @@ def _reply_finished(self, reply: QNetworkReply):

result = json.loads(reply.readAll().data().decode())
if 'panels' in result:
datasets = [item['content'] for item in result['panels'][0]['items']]
datasets = [item['content'] for item in
result['panels'][0]['items']]
else:
datasets = result

tokens = reply.rawHeader(b"X-Resource-Range").data().decode().split("/")
tokens = reply.rawHeader(b"X-Resource-Range").data().decode().split(
"/")
total = tokens[-1]
self.total_count_changed.emit(int(total))
last = tokens[0].split("-")[-1]
Expand Down
2 changes: 1 addition & 1 deletion koordinates/gui/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class ExploreMode:
Popular = auto()
Browse = auto()
Publishers = auto()
Recent = auto()
Recent = auto()
5 changes: 3 additions & 2 deletions koordinates/gui/filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ def set_explore_mode(self, mode: ExploreMode):
if show_filters:
self.advanced_filter_widget.updateGeometry()

if mode in (ExploreMode.Popular,
ExploreMode.Recent) and self.search_line_edit:
if mode in (
ExploreMode.Popular,
ExploreMode.Recent) and self.search_line_edit:
self.search_line_edit.clear()

if mode == ExploreMode.Popular:
Expand Down
2 changes: 1 addition & 1 deletion koordinates/gui/koordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def search(self):

self.results_panel.populate(browser_query, context)

def explore(self, panel: ExplorePanel = ExplorePanel.Popular ):
def explore(self, panel: ExplorePanel = ExplorePanel.Popular):
context = self._current_context
self.browse_header_widget.hide()
self.results_panel.explore(panel, context)
Expand Down
16 changes: 7 additions & 9 deletions koordinates/gui/results_panel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import os
import platform

from functools import partial
from typing import (
List,
Expand All @@ -28,8 +27,7 @@
QSizePolicy,
QWidget,
QLabel,
QStylePainter,
QStyleOption
QStylePainter
)
from qgis.gui import QgsScrollArea

Expand All @@ -45,7 +43,6 @@


class ExplorePanelWidget(QWidget):

CORNER_RADIUS = 4

def __init__(self, content: Dict, parent: Optional[QWidget] = None):
Expand Down Expand Up @@ -73,7 +70,7 @@ def __init__(self, content: Dict, parent: Optional[QWidget] = None):
self.browser.set_datasets(item['content'] for item in content['items'])

vl = QVBoxLayout()
vl.setContentsMargins(12,12,12,0)
vl.setContentsMargins(12, 12, 12, 0)
vl.addWidget(title_label)
vl.addWidget(self.browser)

Expand All @@ -96,8 +93,8 @@ def paintEvent(self, event):

painter.setPen(pen)
painter.drawRoundedRect(self.rect(),
self.CORNER_RADIUS,
self.CORNER_RADIUS)
self.CORNER_RADIUS,
self.CORNER_RADIUS)
painter.restore()


Expand Down Expand Up @@ -130,7 +127,8 @@ def __init__(self):
self.scroll_area.setStyleSheet(
"#qt_scrollarea_viewport{ background: transparent; }")

self.child_items: List[Union[DatasetsBrowserWidget, ExplorePanelWidget]] = []
self.child_items: List[
Union[DatasetsBrowserWidget, ExplorePanelWidget]] = []

self.setMinimumWidth(370)
self.current_mode: Optional[ExploreMode] = None
Expand Down Expand Up @@ -219,7 +217,7 @@ def _reply_finished(self, reply: QNetworkReply):
if reply.error() != QNetworkReply.NoError:
print('error occurred :(')
return
# self.error_occurred.emit(request.reply().errorString())
# self.error_occurred.emit(request.reply().errorString())

result = json.loads(reply.readAll().data().decode())
if 'panels' not in result:
Expand Down

0 comments on commit 1ba533a

Please sign in to comment.