Skip to content

Commit

Permalink
Fix linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
trots committed Oct 25, 2024
1 parent 08d4402 commit f5bbbd6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 37 deletions.
14 changes: 7 additions & 7 deletions chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ def rebuild(self):
text_title = text_title.replace(p, '')

regrex_pattern = re.compile(pattern="["
u"\U00000000-\U00000009"
u"\U0000000B-\U0000001F"
u"\U00000080-\U00000400"
u"\U00000402-\U0000040F"
u"\U00000450-\U00000450"
u"\U00000452-\U0010FFFF"
"]+", flags=re.UNICODE)
u"\U00000000-\U00000009"
u"\U0000000B-\U0000001F"
u"\U00000080-\U00000400"
u"\U00000402-\U0000040F"
u"\U00000450-\U00000450"
u"\U00000452-\U0010FFFF"
"]+", flags=re.UNICODE)

text = regrex_pattern.sub(r'', text_title)

Expand Down
10 changes: 5 additions & 5 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
)


def make_result_row(video_title: str, video_published_time: str, video_duration: str,
views: int, video_link: str, channel_title: str, channel_link: str,
def make_result_row(video_title: str, video_published_time: str, video_duration: str,
views: int, video_link: str, channel_title: str, channel_link: str,
channel_subscribers: int, channel_views: int, channel_joined_date: str,
video_preview_link: str, channel_logo_link: str, video_tags: list[str],
video_duration_timedelta):
view_rate = (str(round(views / channel_subscribers * 100, 2)) + "%") if channel_subscribers > 0 else "-"
return (video_title, video_published_time, video_duration, views, video_link, channel_title,
return (video_title, video_published_time, video_duration, views, video_link, channel_title,
channel_link, channel_subscribers, channel_views, channel_joined_date, view_rate, video_preview_link,
channel_logo_link, video_tags, video_duration_timedelta)

Expand Down Expand Up @@ -41,8 +41,8 @@ def __init__(self, parent, *args):
QAbstractTableModel.__init__(self, parent, *args)
self.result = []
# TODO: Remove header after export fixing. It's unused in this class.
self.header = [self.tr("Title"), self.tr("Published Time"), self.tr("Duration"), self.tr("View Count"), self.tr("Link"),
self.tr("Channel Name"), self.tr("Channel Link"), self.tr("Channel Subscribers"),
self.header = [self.tr("Title"), self.tr("Published Time"), self.tr("Duration"), self.tr("View Count"),
self.tr("Link"), self.tr("Channel Name"), self.tr("Channel Link"), self.tr("Channel Subscribers"),
self.tr("Channel Views"), self.tr("Channel Joined Date"), self.tr("Views/Subscribers")]
self._fields = [
(ResultFields.VideoTitle, self.tr("Title")),
Expand Down
10 changes: 6 additions & 4 deletions widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@


class PixmapLabel(QLabel):
def __init__(self, parent = None):
def __init__(self, parent=None):
super().__init__(parent)
self.setMinimumSize(1, 1)
self.setScaledContents(False)
Expand Down Expand Up @@ -170,9 +170,11 @@ def set_current_index(self, index: QModelIndex):
return

row_data = self._model.result[index.row()]
self._title_label.setText("<a href=\"" + row_data[ResultFields.VideoLink] + "\">" + row_data[ResultFields.VideoTitle] + "</a>")
self._title_label.setText("<a href=\"" + row_data[ResultFields.VideoLink] + "\">" +
row_data[ResultFields.VideoTitle] + "</a>")
self._duration_label.setText(row_data[ResultFields.VideoDuration])
self._channel_title_label.setText("<a href=\"" + row_data[ResultFields.ChannelLink] + "\">" + row_data[ResultFields.ChannelTitle] + "</a>")
self._channel_title_label.setText("<a href=\"" + row_data[ResultFields.ChannelLink] + "\">" +
row_data[ResultFields.ChannelTitle] + "</a>")
update_subscribers = '{0:,}'.format(row_data[ResultFields.ChannelSubscribers]).replace(',', ' ')
self._subscribers_label.setText(update_subscribers + self.tr(" subscribers"))
update_views = '{0:,}'.format(row_data[ResultFields.VideoViews]).replace(',', ' ')
Expand Down Expand Up @@ -240,7 +242,7 @@ def __init__(self, model: ResultTableModel, parent: QWidget = None):
self._chart_combobox.addItem(self.tr("Channels distribution chart"))
self._chart_combobox.addItem(self.tr("Video duration chart"))
self._chart_combobox.addItem(self.tr("Popular title words chart"))

self._chart_combobox.currentIndexChanged.connect(self._on_current_chart_changed)
main_layout.addWidget(self._chart_combobox)

Expand Down
45 changes: 24 additions & 21 deletions youtube-analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ def apply(app: QApplication, theme_index: int):
palette.setColor(QPalette.Highlight, QColor(19, 60, 110))
palette.setColor(QPalette.HighlightedText, Qt.white)
palette.setColor(QPalette.Active, QPalette.Button, QColor(53, 53, 53))
palette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(53, 53, 53).lighter());
palette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(53, 53, 53).lighter());
palette.setColor(QPalette.Disabled, QPalette.Text, QColor(53, 53, 53).lighter());
palette.setColor(QPalette.Disabled, QPalette.Light, QColor(53, 53, 53));
palette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(53, 53, 53).lighter())
palette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(53, 53, 53).lighter())
palette.setColor(QPalette.Disabled, QPalette.Text, QColor(53, 53, 53).lighter())
palette.setColor(QPalette.Disabled, QPalette.Light, QColor(53, 53, 53))
app.setPalette(palette)
else:
palette = QPalette()
Expand All @@ -106,7 +106,7 @@ def apply(app: QApplication, theme_index: int):


class DontAskAgainQuestionDialog(QMessageBox):
def __init__(self, title: str, text: str, parent = None):
def __init__(self, title: str, text: str, parent=None):
super().__init__(parent)
self.setWindowTitle(title)
self.setText(text)
Expand All @@ -122,12 +122,12 @@ def is_dont_ask_again(self):


class AboutDialog(QDialog):
def __init__(self, parent = None):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle(self.tr("About"))
layout = QGridLayout()
layout.setSizeConstraint( QGridLayout.SizeConstraint.SetFixedSize )
layout.setSizeConstraint(QGridLayout.SizeConstraint.SetFixedSize)

row = 0
title = QLabel(app_name)
title.setStyleSheet("font-size: 14px")
Expand All @@ -136,11 +136,12 @@ def __init__(self, parent = None):
layout.addWidget(QLabel(self.tr("Software for analyzing of YouTube search output")), row, 0, 1, 2,
Qt.AlignmentFlag.AlignCenter)
row += 1
layout.addWidget(QLabel(self.tr("Version: ") + version),
layout.addWidget(QLabel(self.tr("Version: ") + version),
row, 0, 1, 2, Qt.AlignmentFlag.AlignCenter)
row += 1
layout.addWidget(QLabel(self.tr("Based on: PySide6, youtube-search-python,\n google-api-python-client, XlsxWriter, isodate.")),
row, 0, 1, 2, Qt.AlignmentFlag.AlignCenter)
layout.addWidget(QLabel(
self.tr("Based on: PySide6, youtube-search-python,\n google-api-python-client, XlsxWriter, isodate.")),
row, 0, 1, 2, Qt.AlignmentFlag.AlignCenter)
row += 1
vertical_spacer = QSpacerItem(1, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)
layout.addItem(vertical_spacer, row, 0, 1, 2, Qt.AlignmentFlag.AlignCenter)
Expand Down Expand Up @@ -168,13 +169,14 @@ def __init__(self, parent = None):

self.setLayout(layout)


class AuthorsDialog(QDialog):
def __init__(self, parent = None):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle(self.tr("Authors"))
layout = QGridLayout()
layout.setSizeConstraint( QGridLayout.SizeConstraint.SetFixedSize )
layout.setSizeConstraint(QGridLayout.SizeConstraint.SetFixedSize)

self._edit_text = QTextEdit()
self._edit_text.setReadOnly(True)
self._edit_text.append(self.tr("The YouTube Analyzer team, in alphabetical order:\n"))
Expand Down Expand Up @@ -368,12 +370,13 @@ def _on_search_clicked(self):
video_idx = self._sort_model.index(i, self._model.get_field_column(ResultFields.VideoTitle))
video_item = self._model.result[i]
video_label = self._create_link_label(video_item[ResultFields.VideoLink], video_item[ResultFields.VideoTitle])
self._table_view.setIndexWidget(video_idx, video_label);
self._table_view.setIndexWidget(video_idx, video_label)

channel_idx = self._sort_model.index(i, self._model.get_field_column(ResultFields.ChannelTitle))
channel_label = self._create_link_label(video_item[ResultFields.ChannelLink], video_item[ResultFields.ChannelTitle])
self._table_view.setIndexWidget(channel_idx, channel_label);

channel_label = self._create_link_label(video_item[ResultFields.ChannelLink],
video_item[ResultFields.ChannelTitle])
self._table_view.setIndexWidget(channel_idx, channel_label)

self._table_view.resizeColumnsToContents()
else:
dialog = QMessageBox()
Expand All @@ -382,7 +385,7 @@ def _on_search_clicked(self):
dialog.setIcon(QMessageBox.Critical)
dialog.setDetailedText(engine.error)
dialog.exec()

QApplication.restoreOverrideCursor()
self._search_line_edit.setDisabled(False)
self._search_button.setDisabled(False)
Expand Down Expand Up @@ -461,7 +464,7 @@ def _create_engine(self):
return YoutubeGrepEngine(self._model, request_limit)
else:
return YoutubeApiEngine(self._model, request_limit, api_key)

def _create_link_label(self, link: str, text: str):
label = QLabel("<a href=\"" + link + "\">" + text + "</a>")
label_size_policy = label.sizePolicy()
Expand Down

0 comments on commit f5bbbd6

Please sign in to comment.