mirror of
https://github.com/aclist/dztui.git
synced 2026-08-28 10:47:15 +02:00
chore: clear linting errors
This commit is contained in:
parent
46a215a472
commit
45f1c5d8c6
@ -4,7 +4,6 @@ import struct
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from shlex import shlex
|
||||
from typing import BinaryIO, Union
|
||||
|
||||
from packaging.version import Version
|
||||
@ -73,7 +72,7 @@ class PackedData:
|
||||
def unpack(cls, data: BinaryIO):
|
||||
r = []
|
||||
for key, value in cls.__annotations__.items():
|
||||
if value == str:
|
||||
if type(value) is str:
|
||||
f = data.read(8).rstrip(b"\x00\x00").decode()
|
||||
else:
|
||||
fmt = endian + (value.fmt)
|
||||
@ -269,6 +268,7 @@ class AppNotInstalledError(Exception):
|
||||
|
||||
class AppMovedError(Exception):
|
||||
"""VDF points to a nonexistent location on disk"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@ -372,10 +372,7 @@ def get_version(file: Path) -> FileVersion:
|
||||
shift = entry.data_or_subdir & ~(1 << 31)
|
||||
seek_to_hex(hex(offset + shift), f)
|
||||
table = RESOURCE_DIRECTORY_TABLE.unpack(f)
|
||||
total = (
|
||||
table.number_of_name_entries
|
||||
+ table.number_of_id_entries
|
||||
)
|
||||
total = table.number_of_name_entries + table.number_of_id_entries
|
||||
for entry in range(total):
|
||||
entry = RESOURCE_DIRECTORY_ENTRY.unpack(f)
|
||||
break
|
||||
@ -423,6 +420,7 @@ def get_pefile_path(steam_path: Path, appid: int) -> Path:
|
||||
pe_path = app_path / f"steamapps/common/{name}/{binary}"
|
||||
return pe_path
|
||||
|
||||
|
||||
def get_app_path(folders_path: Path, appid: int) -> Path:
|
||||
app_path = None
|
||||
|
||||
|
||||
@ -11,12 +11,14 @@ from dzgui.util.bash import concat_bash_args
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def query_defunct():
|
||||
def query_defunct() -> None:
|
||||
pass
|
||||
|
||||
|
||||
# TODO: unimplemented
|
||||
#cf.
|
||||
# cf.
|
||||
#!/usr/bin/env bash
|
||||
#query_defunct(){
|
||||
# query_defunct(){
|
||||
# readarray -t modlist <<< "$@"
|
||||
# local max=${#modlist[@]}
|
||||
# concat(){
|
||||
@ -41,9 +43,9 @@ def query_defunct():
|
||||
# | select(.filename|contains("screenshot")|not)
|
||||
# | "\(.file_size) \(.publishedfileid)"')
|
||||
# <<< "$result" awk '{print $2}'
|
||||
#}
|
||||
# }
|
||||
#
|
||||
#query_defunct "3576065083"
|
||||
# query_defunct "3576065083"
|
||||
|
||||
|
||||
def concat_mods(mods: list[str]) -> str:
|
||||
@ -51,6 +53,7 @@ def concat_mods(mods: list[str]) -> str:
|
||||
mods[mod] = "@" + mod
|
||||
return ";".join(mods)
|
||||
|
||||
|
||||
# TEST: set config to name=user, use official server and no mods,
|
||||
# ensure that formatted string is identical to fixture
|
||||
def connect(addr: str, appid: int, name: str, mods: list) -> None:
|
||||
@ -58,13 +61,13 @@ def connect(addr: str, appid: int, name: str, mods: list) -> None:
|
||||
# TODO: concat_mods(mods):
|
||||
# @<mod>;@<mod>;
|
||||
params = [
|
||||
f"-connect={addr}",
|
||||
"-nolauncher",
|
||||
"-nosplash",
|
||||
"-skipintro",
|
||||
f"-name={name}",
|
||||
f"-mod={concat}"
|
||||
]
|
||||
f"-connect={addr}",
|
||||
"-nolauncher",
|
||||
"-nosplash",
|
||||
"-skipintro",
|
||||
f"-name={name}",
|
||||
f"-mod={concat}",
|
||||
]
|
||||
# TODO: get steam launch command from configs
|
||||
# args = concat_bash_args()
|
||||
#
|
||||
@ -130,8 +133,8 @@ def gen_shortcut() -> None:
|
||||
show user account name, select outer steam id
|
||||
steam/userdata/<steamid_32>/config/shortcuts.vdf
|
||||
"""
|
||||
#STEAMID_MAGIC = 76561197960265728
|
||||
# STEAMID_MAGIC = 76561197960265728
|
||||
# STEAMID_64 - STEAMID_MAGIC = STEAMID32
|
||||
# or get right-most 32 bits
|
||||
#STEAMID_64 & 0xFFFFFFFF
|
||||
# STEAMID_64 & 0xFFFFFFFF
|
||||
pass
|
||||
|
||||
@ -7,7 +7,7 @@ from warnings import deprecated
|
||||
from concurrent.futures import wait
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Literal, TYPE_CHECKING
|
||||
from typing import Any, Callable, Literal, Union, TYPE_CHECKING
|
||||
|
||||
import dzgui.api.pefile as PeFile
|
||||
import dzgui.api.servers as Servers
|
||||
@ -112,6 +112,14 @@ class Emitter(GObject.GObject):
|
||||
"""User invoked right movement keybinding from ServerTreeView"""
|
||||
pass
|
||||
|
||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())
|
||||
def distcalc_started(self) -> None:
|
||||
pass
|
||||
|
||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object, object,))
|
||||
def distcalc_ended(self, dist: Union[str, None], context: Union["ServerTab", NotebookPage]) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class Controller(GObject.GObject):
|
||||
def __init__(self) -> None:
|
||||
@ -400,7 +408,7 @@ class Controller(GObject.GObject):
|
||||
|
||||
self.mediator.notebook.set_page_by_enum(button.opens)
|
||||
|
||||
def dump_api(self):
|
||||
def dump_api(self) -> None:
|
||||
key = self.query_config(Preferences.STEAM)
|
||||
job = Servers.query_api
|
||||
params = Servers.params
|
||||
@ -646,7 +654,7 @@ class Controller(GObject.GObject):
|
||||
)
|
||||
self.push_data(data)
|
||||
|
||||
def cleanup(self):
|
||||
def cleanup(self) -> None:
|
||||
treeview = self.get_active_treeview()
|
||||
context = self.get_active_context()
|
||||
# TODO: rename signal
|
||||
@ -664,7 +672,7 @@ class Controller(GObject.GObject):
|
||||
def push_data(self, data: tuple, mode: FilterMode) -> None:
|
||||
|
||||
treeview = self.get_active_treeview()
|
||||
context = self.get_active_context()
|
||||
# context = self.get_active_context()
|
||||
manager = treeview.get_filter_man()
|
||||
|
||||
if data is None:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from typing import Literal
|
||||
from typing import Literal, TYPE_CHECKING
|
||||
|
||||
from dzgui.const.enum import FilterMode
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, NO_PADDING
|
||||
@ -14,9 +14,12 @@ from gi.repository import Gtk, Gdk, Pango, GLib # noqa E402
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dzgui.controllers.mc import Controller
|
||||
|
||||
|
||||
class FilterPanel(Gtk.Box):
|
||||
def __init__(self, controller):
|
||||
def __init__(self, controller: "Controller") -> None:
|
||||
super().__init__(spacing=6, vexpand=False)
|
||||
|
||||
self.default_filters = {
|
||||
@ -85,8 +88,12 @@ class FilterPanel(Gtk.Box):
|
||||
self.keyword_entry.connect("activate", self._on_keyword_enter)
|
||||
self.keyword_entry.connect("key-press-event", self._on_keyword_keypress)
|
||||
|
||||
self.emitter.connect("request_keyword_focus", lambda _: self.keyword_entry.grab_focus())
|
||||
self.emitter.connect("request_maps_focus", lambda _: self.maps_entry.grab_focus())
|
||||
self.emitter.connect(
|
||||
"request_keyword_focus", lambda _: self.keyword_entry.grab_focus()
|
||||
)
|
||||
self.emitter.connect(
|
||||
"request_maps_focus", lambda _: self.maps_entry.grab_focus()
|
||||
)
|
||||
|
||||
completion = Gtk.EntryCompletion(inline_completion=True)
|
||||
completion.set_text_column(0)
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
from typing import Literal, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from dzgui.views.components.buttonbox import ButtonBox
|
||||
from dzgui.views.components.filter_panel import FilterPanel
|
||||
from dzgui.views.components.mod_panel import ModSelectionPanel
|
||||
from dzgui.views.components.buttons import RefreshButton, KeysButton
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, FILL, NO_PADDING
|
||||
from dzgui.util.strings import atomic_buttons
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib # noqa E402
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dzgui.controllers.mc import Controller
|
||||
from GLib import SOURCE_REMOVE
|
||||
|
||||
|
||||
class RightPanel(Gtk.Box):
|
||||
def __init__(self, controller: "Controller"):
|
||||
@ -21,8 +21,8 @@ class RightPanel(Gtk.Box):
|
||||
|
||||
self.controller = controller
|
||||
self.controller.register_widget("right_panel", self)
|
||||
self.emitter = controller.get_emitter()
|
||||
|
||||
emitter = controller.get_emitter()
|
||||
emitter.connect("request_button_box_focus", self.focus_button_box)
|
||||
|
||||
self.button_vbox = ButtonBox(controller)
|
||||
@ -41,13 +41,13 @@ class RightPanel(Gtk.Box):
|
||||
def reinit_maps(self, rows: list) -> None:
|
||||
self.controller.reinit_map_store()
|
||||
# TODO: communicate with controller
|
||||
#self.controller.clear_map_store()
|
||||
#map_store.append(["All maps"])
|
||||
# self.controller.clear_map_store()
|
||||
# map_store.append(["All maps"])
|
||||
self.selected = "All maps"
|
||||
self.filters_vbox.set_unique_maps(rows)
|
||||
|
||||
# TODO: reference
|
||||
#def _on_ping_clicked(self, button: Gtk.Button) -> None:
|
||||
# def _on_ping_clicked(self, button: Gtk.Button) -> None:
|
||||
# block_signals()
|
||||
# def _update_pings():
|
||||
# # TODO
|
||||
|
||||
@ -20,6 +20,7 @@ class Statusbar(Gtk.Grid):
|
||||
|
||||
self.controller = controller
|
||||
self.controller.register_widget("statusbar", self)
|
||||
self.emitter = controller.get_emitter()
|
||||
|
||||
self.playercount = ""
|
||||
self.statusbar = Gtk.Statusbar()
|
||||
@ -45,19 +46,17 @@ class Statusbar(Gtk.Grid):
|
||||
controller.mediator.notebook.connect_after(
|
||||
"switch-page", self._on_notebook_page_changed
|
||||
)
|
||||
self.connect("server_row_changed", self._on_server_row_changed)
|
||||
self.connect("server_page_changed", self._on_server_page_changed)
|
||||
self.emitter.connect("distcalc_started", self._on_distcalc_started)
|
||||
# TODO:
|
||||
self.connect("distcalc_ended", self._on_distcalc_ended)
|
||||
|
||||
self.connect("server_page_changed", self._on_server_page_changed)
|
||||
|
||||
# TODO: move to emitter
|
||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object,))
|
||||
def server_page_changed(self, tab: ServerTab) -> None:
|
||||
pass
|
||||
|
||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())
|
||||
def server_row_changed(self) -> None:
|
||||
pass
|
||||
|
||||
@GObject.Signal(
|
||||
flags=GObject.SignalFlags.RUN_LAST,
|
||||
arg_types=(
|
||||
@ -123,6 +122,7 @@ class Statusbar(Gtk.Grid):
|
||||
|
||||
self.set_by_context(context, count)
|
||||
tree = self.controller.get_active_treeview()
|
||||
# TODO: emit page change signal on emitter, treeview catches signal and calls distcalc
|
||||
tree.emit("distcalc_started")
|
||||
|
||||
def pop(self, context: Union["ServerTab", "NotebookPage"]) -> None:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import logging
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from dzgui.const.constants import SEPARATOR
|
||||
from dzgui.util.keys import is_navkey
|
||||
@ -20,7 +20,7 @@ if TYPE_CHECKING:
|
||||
|
||||
class TreeView(CursorMixin, Gtk.TreeView): # type: ignore
|
||||
def __init__(
|
||||
self, controller: "Controller", menu: "ContextMenuGroup" = None
|
||||
self, controller: "Controller", menu: Optional["ContextMenuGroup"] = None
|
||||
) -> None:
|
||||
super().__init__(
|
||||
enable_search=False,
|
||||
@ -147,7 +147,7 @@ class TreeView(CursorMixin, Gtk.TreeView): # type: ignore
|
||||
name = self.get_value_at_index(0)
|
||||
return name
|
||||
|
||||
def select_first_row(self):
|
||||
def select_first_row(self) -> None:
|
||||
sel = self.get_selection()
|
||||
self._on_tree_selection_changed(sel)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import multiprocessing
|
||||
from typing import Any, Self
|
||||
from warnings import deprecated
|
||||
|
||||
from dzgui.const.enum import ContextMenu, ContextMenuGroup, FilterMode, ServerTab
|
||||
from dzgui.const.enum import ContextMenu, ContextMenuGroup, ServerTab
|
||||
from dzgui.api.servers import Record
|
||||
from dzgui.model.filtered_model import FilteredModelManager
|
||||
from dzgui.util.dist import CalcDist
|
||||
@ -203,13 +203,14 @@ class ServerTreeView(TreeView):
|
||||
self.current_proc.terminate()
|
||||
|
||||
def _on_distcalc_started(self, treeview: Self):
|
||||
bar = self.controller.get_statusbar()
|
||||
# bar = self.controller.get_statusbar()
|
||||
|
||||
record = self.get_record()
|
||||
if record is None:
|
||||
return
|
||||
|
||||
bar.emit("server_row_changed")
|
||||
self.emitter.emit("distcalc_started")
|
||||
# bar.emit("server_row_changed")
|
||||
cache = self.controller.get_dist_cache()
|
||||
|
||||
if record.ip in cache:
|
||||
@ -297,7 +298,7 @@ class ServerTreeView(TreeView):
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
mod_context_items = [ContextMenu.OPEN_WORKSHOP, ContextMenu.DELETE_MOD]
|
||||
# mod_context_items = [ContextMenu.OPEN_WORKSHOP, ContextMenu.DELETE_MOD]
|
||||
|
||||
# TODO: dynamic menu entries
|
||||
# for row in items:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user