Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
m3nu committed Mar 16, 2024
1 parent 504be70 commit 7bbf372
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 44 deletions.
1 change: 1 addition & 0 deletions requirements.d/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
brew 'create-dmg'
brew 'qt'
brew 'hub'
brew 'pre-commit'
brew 'xmlstarlet'
cask 'qt-creator'
cask 'sparkle'
2 changes: 1 addition & 1 deletion src/vorta/store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from playhouse import signals

from vorta.store.utils import slugify
# from vorta.views.utils import get_exclusion_presets
from vorta.views.utils import get_exclusion_presets

DB = pw.Proxy()
logger = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion src/vorta/store/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unicodedata
import re
import unicodedata


def slugify(value):
"""
Expand Down
19 changes: 9 additions & 10 deletions src/vorta/utils.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import argparse
import errno
import math
import getpass
import math
import os
import re
import socket
import sys
from datetime import datetime as dt, timedelta
from datetime import datetime as dt
from functools import reduce
from typing import Any, Callable, Iterable, List, Optional, Tuple, TypeVar

from PyQt6 import QtCore
from PyQt6.QtCore import QFileInfo, QThread, pyqtSignal, Qt
from PyQt6.QtWidgets import (QApplication, QFileDialog, QSystemTrayIcon,
QListWidgetItem, QTableWidgetItem)
from PyQt6.QtWidgets import (
QApplication,
QFileDialog,
QSystemTrayIcon,
)

from vorta.network_status.abc import NetworkStatusMonitor
from vorta.borg._compatibility import BorgCompatibility
from vorta.log import logger

from vorta.network_status.abc import NetworkStatusMonitor

# Used to store whether a user wanted to override the
# default directory for the --development flag
Expand Down Expand Up @@ -98,14 +99,14 @@ def get_private_keys() -> List[str]:
return available_private_keys



Number = TypeVar("Number", int, float)


def clamp(n: Number, min_: Number, max_: Number) -> Number:
"""Restrict the number n inside a range"""
return min(max_, max(n, min_))


def get_network_status_monitor():
global _network_status_monitor
if _network_status_monitor is None:
Expand Down Expand Up @@ -175,7 +176,6 @@ def get_asset(path):
return os.path.join(bundle_dir, path)



def parse_args():
parser = argparse.ArgumentParser(description='Vorta Backup GUI for Borg.')
parser.add_argument('--version', '-V', action='store_true', help="Show version and exit.")
Expand Down Expand Up @@ -259,7 +259,6 @@ def format_archive_name(profile, archive_name_tpl):
SHELL_PATTERN_ELEMENT = re.compile(r'([?\[\]*])')



def is_system_tray_available():
app = QApplication.instance()
if app is None:
Expand Down
6 changes: 3 additions & 3 deletions src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import sys
from typing import Dict, Optional
from datetime import timedelta
from typing import Dict, Optional

from PyQt6 import QtCore, uic
from PyQt6.QtCore import QItemSelectionModel, QMimeData, QPoint, Qt, pyqtSlot
Expand Down Expand Up @@ -36,15 +36,15 @@
from vorta.utils import (
borg_compat,
choose_file_dialog,
find_best_unit_for_sizes,
format_archive_name,
get_asset,
pretty_bytes,
find_best_unit_for_sizes
)
from vorta.views import diff_result, extract_dialog
from vorta.views.diff_result import DiffResultDialog, DiffTree
from vorta.views.extract_dialog import ExtractDialog, ExtractTree
from vorta.views.utils import get_colored_icon, SizeItem
from vorta.views.utils import SizeItem, get_colored_icon
from vorta.views.workers.mount_points_worker import MountPointsWorker

uifile = get_asset('UI/archivetab.ui')
Expand Down
3 changes: 1 addition & 2 deletions src/vorta/views/schedule_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from vorta.scheduler import ScheduleStatusType
from vorta.store.models import BackupProfileMixin, EventLogModel, WifiSettingModel
from vorta.utils import get_asset
from vorta.views.workers.wifi_list_worker import WifiListWorker
from vorta.views.utils import get_colored_icon
from vorta.views.workers.wifi_list_worker import WifiListWorker

uifile = get_asset('UI/scheduletab.ui')
ScheduleUI, ScheduleBase = uic.loadUiType(uifile)
Expand Down Expand Up @@ -193,7 +193,6 @@ def set_wifi_list(self, wifi_list):
item.setCheckState(QtCore.Qt.CheckState.Unchecked)
self.wifiListWidget.addItem(item)


def draw_next_scheduled_backup(self):
status = self.app.scheduler.next_job_for_profile(self.profile().id)
if status.type in (
Expand Down
10 changes: 3 additions & 7 deletions src/vorta/views/source_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@
)

from vorta.store.models import BackupProfileMixin, SettingsModel, SourceFileModel
from vorta.views.workers.file_path_info_worker import FilePathInfoAsync
from vorta.utils import (
choose_file_dialog,
get_asset,
pretty_bytes
)
from vorta.utils import choose_file_dialog, get_asset, pretty_bytes
from vorta.views.exclude_dialog import ExcludeDialog
from vorta.views.utils import get_colored_icon, SizeItem
from vorta.views.utils import SizeItem, get_colored_icon
from vorta.views.workers.file_path_info_worker import FilePathInfoAsync

uifile = get_asset('UI/sourcetab.ui')
SourceUI, SourceBase = uic.loadUiType(uifile)
Expand Down
2 changes: 1 addition & 1 deletion src/vorta/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os
import sys

from PyQt6.QtGui import QIcon, QImage, QPixmap
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QIcon, QImage, QPixmap
from PyQt6.QtWidgets import QTableWidgetItem

from vorta.utils import get_asset, uses_dark_mode
Expand Down
15 changes: 5 additions & 10 deletions src/vorta/views/workers/file_path_info_worker.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@

from datetime import datetime as dt, timedelta
import unicodedata
import fnmatch
import os
import sys
import re
import fnmatch
import psutil
import sys
import unicodedata

from PyQt6 import QtCore
from PyQt6.QtCore import QFileInfo, QThread, pyqtSignal, Qt
from PyQt6.QtWidgets import (QApplication, QFileDialog, QSystemTrayIcon,
QListWidgetItem, QTableWidgetItem)
from PyQt6.QtCore import QFileInfo, QThread, pyqtSignal


class FilePathInfoAsync(QThread):
Expand Down Expand Up @@ -38,6 +32,7 @@ def normalize_path(path):
# Windows and Unix filesystems allow different forms, so users always have to enter an exact match.
return unicodedata.normalize('NFD', path) if sys.platform == 'darwin' else path


def get_path_datasize(path, exclude_patterns):
file_info = QFileInfo(path)

Expand Down
12 changes: 5 additions & 7 deletions src/vorta/views/workers/mount_points_worker.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@


import psutil
from PyQt6.QtCore import QThread, Qt, pyqtSignal
from PyQt6.QtWidgets import QTableWidgetItem
from PyQt6.QtCore import QThread, pyqtSignal

from vorta.store.models import ArchiveModel, SettingsModel
from vorta.views.utils import get_colored_icon, SizeItem
from vorta.utils import borg_compat, pretty_bytes, find_best_unit_for_sizes, SHELL_PATTERN_ELEMENT
from vorta.utils import (
SHELL_PATTERN_ELEMENT,
borg_compat,
)

SIZE_DECIMAL_DIGITS = 1

Expand Down
5 changes: 3 additions & 2 deletions src/vorta/views/workers/wifi_list_worker.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

import logging

from PyQt6.QtCore import QThread, pyqtSignal

from vorta.utils import get_network_status_monitor
from vorta.store.models import WifiSettingModel
from vorta.utils import get_network_status_monitor

logger = logging.getLogger(__name__)


class WifiListWorker(QThread):
signal = pyqtSignal(list)

Expand Down

0 comments on commit 7bbf372

Please sign in to comment.