Linting code

This commit is contained in:
jeffser 2024-08-04 21:20:47 -06:00
parent dd95e3df7e
commit 6ba3719031
6 changed files with 32 additions and 15 deletions

View File

@ -6,8 +6,8 @@ import os
import logging import logging
from pytube import YouTube from pytube import YouTube
from html2text import html2text from html2text import html2text
from . import connection_handler
from gi.repository import Adw, Gtk from gi.repository import Adw, Gtk
from . import connection_handler
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# CLEAR CHAT | WORKS # CLEAR CHAT | WORKS
@ -307,8 +307,8 @@ def attach_file_response(self, file_dialog, result):
return return
self.attach_file(file.get_path(), file_type) self.attach_file(file.get_path(), file_type)
def attach_file(self, filter): def attach_file(self, file_filter):
file_dialog = Gtk.FileDialog(default_filter=filter) file_dialog = Gtk.FileDialog(default_filter=file_filter)
file_dialog.open(self, None, lambda file_dialog, result: attach_file_response(self, file_dialog, result)) file_dialog.open(self, None, lambda file_dialog, result: attach_file_response(self, file_dialog, result))
# YouTube caption | WORKS # YouTube caption | WORKS

View File

@ -1,18 +1,21 @@
# internal.py
"""
Handles paths, they can be different if the app is running as a Flatpak
"""
import os import os
app_id = "com.jeffser.Alpaca" APP_ID = "com.jeffser.Alpaca"
in_flatpak = True if os.getenv("FLATPAK_ID") else False IN_FLATPAK = bool(os.getenv("FLATPAK_ID"))
def get_xdg_home(env, default): def get_xdg_home(env, default):
if in_flatpak: if IN_FLATPAK:
return os.getenv(env) return os.getenv(env)
else: base = os.getenv(env) or os.path.expanduser(default)
base = os.getenv(env) or os.path.expanduser(default) path = os.path.join(base, APP_ID)
path = os.path.join(base, app_id) if not os.path.exists(path):
if not os.path.exists(path): os.makedirs(path)
os.makedirs(path) return path
return path
data_dir = get_xdg_home("XDG_DATA_HOME", "~/.local/share") data_dir = get_xdg_home("XDG_DATA_HOME", "~/.local/share")

View File

@ -1,5 +1,10 @@
# local_instance.py # local_instance.py
import subprocess, os, threading """
Handles running, stopping and resetting the integrated Ollama instance
"""
import subprocess
import os
import threading
from time import sleep from time import sleep
from logging import getLogger from logging import getLogger
from .internal import data_dir, cache_dir from .internal import data_dir, cache_dir
@ -39,4 +44,3 @@ def reset():
stop() stop()
sleep(1) sleep(1)
start() start()

View File

@ -16,7 +16,9 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
"""
Main script run at launch, handles actions, about dialog and the app itself (not the window)
"""
import sys import sys
import logging import logging
import gi import gi

View File

@ -1,3 +1,8 @@
#table_widget
"""
Handles the table widget shown in chat responses
"""
import gi import gi
from gi.repository import Adw from gi.repository import Adw
from gi.repository import Gtk, GObject, Gio from gi.repository import Gtk, GObject, Gio

View File

@ -16,6 +16,9 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
"""
Handles the main window
"""
import gi import gi
gi.require_version('GtkSource', '5') gi.require_version('GtkSource', '5')