Skip to content

Commit

Permalink
Linting code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffser committed Aug 5, 2024
1 parent dd95e3d commit 6ba3719
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import logging
from pytube import YouTube
from html2text import html2text
from . import connection_handler
from gi.repository import Adw, Gtk
from . import connection_handler

logger = logging.getLogger(__name__)
# CLEAR CHAT | WORKS
Expand Down Expand Up @@ -307,8 +307,8 @@ def attach_file_response(self, file_dialog, result):
return
self.attach_file(file.get_path(), file_type)

def attach_file(self, filter):
file_dialog = Gtk.FileDialog(default_filter=filter)
def attach_file(self, file_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))

# YouTube caption | WORKS
Expand Down
21 changes: 12 additions & 9 deletions src/internal.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# internal.py
"""
Handles paths, they can be different if the app is running as a Flatpak
"""
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):
if in_flatpak:
if IN_FLATPAK:
return os.getenv(env)
else:
base = os.getenv(env) or os.path.expanduser(default)
path = os.path.join(base, app_id)
if not os.path.exists(path):
os.makedirs(path)
return path
base = os.getenv(env) or os.path.expanduser(default)
path = os.path.join(base, APP_ID)
if not os.path.exists(path):
os.makedirs(path)
return path


data_dir = get_xdg_home("XDG_DATA_HOME", "~/.local/share")
Expand Down
8 changes: 6 additions & 2 deletions src/local_instance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# 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 logging import getLogger
from .internal import data_dir, cache_dir
Expand Down Expand Up @@ -39,4 +44,3 @@ def reset():
stop()
sleep(1)
start()

4 changes: 3 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# 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 logging
import gi
Expand Down
5 changes: 5 additions & 0 deletions src/table_widget.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#table_widget
"""
Handles the table widget shown in chat responses
"""

import gi
from gi.repository import Adw
from gi.repository import Gtk, GObject, Gio
Expand Down
3 changes: 3 additions & 0 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""
Handles the main window
"""

import gi
gi.require_version('GtkSource', '5')
Expand Down

0 comments on commit 6ba3719

Please sign in to comment.