Skip to content

Commit

Permalink
fix all except invalid-name
Browse files Browse the repository at this point in the history
  • Loading branch information
Stunkymonkey committed Dec 29, 2023
1 parent 36d2eba commit 5570052
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/nautilus_open_any_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

@dataclass(frozen=True)
class Terminal:
"""Data class representing a terminal configuration."""
name: str
workdir_arguments: Optional[list[str]] = None
new_tab_arguments: Optional[list[str]] = None
Expand Down Expand Up @@ -92,9 +93,8 @@ class Terminal:

FLATPAK_PARMS = ["off", "system", "user"]

global terminal
terminal = "gnome-terminal"
terminal_cmd: list[str] = None # type: ignore
terminal_cmd: Optional[list[str]] = None
terminal_data: Terminal = TERMINALS["gnome-terminal"]
new_tab = False
flatpak = FLATPAK_PARMS[0]
Expand Down Expand Up @@ -147,6 +147,7 @@ def read_os_release():

@cache
def distro_id():
"""get the name of your linux distribution"""
try:
return dict(read_os_release())["ID"]
except OSError:
Expand All @@ -167,10 +168,11 @@ def open_terminal_in_file(filename):
# This is required
cmd.append(filename)

Popen(cmd, cwd=filename)
Popen(cmd, cwd=filename) # pylint: disable=consider-using-with


def set_terminal_args(*_args):
"""set the terminal_cmd to the correct values"""
global new_tab
global flatpak
global terminal_cmd
Expand Down Expand Up @@ -211,11 +213,11 @@ def set_terminal_args(*_args):
class OpenAnyTerminalShortcutProvider(
GObject.GObject, Nautilus.LocationWidgetProvider
): # pylint: disable=too-few-public-methods
"""Provide shortcuts for opening terminals in Nautilus."""
"""Provide keyboard shortcuts for opening terminals in Nautilus."""

def __init__(self):
source = Gio.SettingsSchemaSource.get_default()
if source.lookup(GSETTINGS_PATH, True):
gsettings_source = Gio.SettingsSchemaSource.get_default()
if gsettings_source.lookup(GSETTINGS_PATH, True):
self._gsettings = Gio.Settings.new(GSETTINGS_PATH)
self._gsettings.connect("changed", self._bind_shortcut)
self._create_accel_group()
Expand All @@ -238,6 +240,7 @@ def _open_terminal(self, *_args):
open_terminal_in_file(filename)

def get_widget(self, uri, window):
"""follows uri and sets the correct window"""
self._uri = uri
if self._window:
self._window.remove_accel_group(self._accel_group)
Expand Down Expand Up @@ -268,7 +271,7 @@ def _open_terminal(self, file_):
if file_.is_directory():
cmd.extend(["cd", shlex.quote(unquote(result.path)), ";", "exec", "$SHELL"])

Popen(cmd)
Popen(cmd) # pylint: disable=consider-using-with
else:
filename = Gio.File.new_for_uri(file_.get_uri()).get_path()
open_terminal_in_file(filename)
Expand All @@ -280,6 +283,7 @@ def _menu_background_activate_cb(self, menu, file_):
self._open_terminal(file_)

def get_file_items(self, *args):
"""Generates a list of menu items for a file or folder in the Nautilus file manager."""
# `args` will be `[files: List[Nautilus.FileInfo]]` in Nautilus 4.0 API,
# and `[window: Gtk.Widget, files: List[Nautilus.FileInfo]]` in Nautilus 3.0 API.

Expand Down Expand Up @@ -313,6 +317,7 @@ def get_file_items(self, *args):
return items

def get_background_items(self, *args):
"""Generates a list of background menu items for a file or folder in the Nautilus file manager."""
# `args` will be `[folder: Nautilus.FileInfo]` in Nautilus 4.0 API,
# and `[window: Gtk.Widget, file: Nautilus.FileInfo]` in Nautilus 3.0 API.

Expand Down

0 comments on commit 5570052

Please sign in to comment.