Skip to content

Commit

Permalink
refactor: revert to [c] to copy. handle circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbrayo committed Nov 1, 2024
1 parent 5c95dd7 commit f8cae58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
3 changes: 2 additions & 1 deletion gptme/clipboard.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import platform
import subprocess

from .util import get_installed_programs

text = ""

Expand All @@ -13,6 +12,8 @@ def set_copytext(new_text: str):

def copy() -> bool:
"""return True if successful"""
from .util import get_installed_programs

global text
if platform.system() == "Linux":
# check if xclip or wl-clipboard is installed
Expand Down
14 changes: 1 addition & 13 deletions gptme/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import functools
import re
import sys
import tty
import termios
import textwrap
from datetime import datetime, timedelta
Expand Down Expand Up @@ -341,6 +340,7 @@ def path_with_tilde(path: Path) -> str:
return path_str.replace(home, "~", 1)
return path_str


def get_system_distro() -> str:
"""Get the system distribution name."""
regex = re.compile(r"^NAME=\"?([^\"]+)\"?")
Expand All @@ -360,15 +360,3 @@ def get_installed_programs(candidates: tuple[str, ...]) -> set[str]:
if shutil.which(candidate) is not None:
installed.add(candidate)
return installed

def listen_for_character():
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
except KeyboardInterrupt:
ch = "\x03" # ASCII code for Ctrl+C
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch

0 comments on commit f8cae58

Please sign in to comment.