Skip to content

Commit fa31ce3

Browse files
committed
refactor: move pyperclip deps to gui module
1 parent 184197b commit fa31ce3

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

lires/core/utils.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import subprocess, os, platform, sys, threading
44
from typing import Callable, TypeVar
55
from ..confReader import LOG_FILE, ASSETS_PATH
6-
import pyperclip as pc
76
from functools import wraps
87
from uuid import uuid4
98

@@ -164,18 +163,6 @@ def openFile(filepath):
164163
else: # linux variants
165164
subprocess.Popen(('xdg-open', filepath))
166165

167-
def copy2clip(text: str):
168-
# assert isinstance(text, str), "copy2clip only takes string as input"
169-
# if platform.system() == 'Darwin': # macOS
170-
# cmd = 'echo '+text.strip()+'|pbcopy'
171-
# elif platform.system() == 'Windows': # Windows
172-
# cmd = 'echo '+text.strip()+'|clip'
173-
# else: # linux variants
174-
# cmd = 'echo '+"\""+ text.strip()+ "\"" + "| xclip -sel clip"
175-
# subprocess.check_call(cmd, shell=True)
176-
pc.copy(text.strip("\""))
177-
return True
178-
179166
def isWebURL(text: str):
180167
regex = re.compile(
181168
r'^(?:http|ftp)s?://' # http:// or https://

lires_qt/widgets/fileSelector.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from PyQt6.QtWidgets import QHBoxLayout, QItemDelegate, QMessageBox, QStyleOptionViewItem, QVBoxLayout, QFrame, QAbstractItemView, QTableView, QFileDialog, QStyledItemDelegate, QStyle
44
from PyQt6.QtGui import QAction, QShortcut, QColor
55
from PyQt6 import QtGui, QtCore
6+
import pyperclip
67
import typing, copy, functools
78
from typing import List, overload, Union, Literal, Callable, Optional, cast
89

@@ -14,11 +15,15 @@
1415
from lires.core import globalVar as G
1516
from lires.core.dataClass import DataPoint, DataList, DataTags, DataTableList
1617
from lires.core.dataSearcher import StringSearchT, DataSearcher
17-
from lires.core.utils import copy2clip, openFile
18+
from lires.core.utils import openFile
1819
from lires.core.encryptClient import generateHexHash
1920
from lires.confReader import getConf, getConfV, getServerURL
2021
from lires.types.configT import _ConfFontSizeT
2122

23+
def copy2clip(text: str):
24+
pyperclip.copy(text.strip("\""))
25+
return True
26+
2227
class FileSelectorGUI(MainWidgetBase):
2328
def __init__(self, parent):
2429
super().__init__(parent)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ dependencies = [
4343

4444
# used by both core and ai, may be removed in the future
4545
"markdown",
46-
"pyperclip",
4746
]
4847

4948
[project.optional-dependencies]
@@ -69,6 +68,7 @@ gui = [
6968
"darkdetect",
7069
"PyQt6",
7170
"PyQt6-WebEngine",
71+
"pyperclip",
7272
]
7373
ai = [
7474
"safetensors <= 0.3.2", # 0.3.3 or higher seems requires rust installed

0 commit comments

Comments
 (0)