pyperclip not required

This commit is contained in:
Kirill Markin 2024-10-30 08:58:24 +01:00
parent 42326ae797
commit ad36a75a7a
3 changed files with 18 additions and 12 deletions

View file

@ -206,16 +206,23 @@ def save_repo_to_text(path='.', output_dir=None) -> str:
# Read the contents of the generated file
with open(output_file, 'r') as file:
repo_text = file.read()
# Copy the contents to the clipboard
# Try to copy to clipboard if pyperclip is installed
try:
import pyperclip
pyperclip.copy(repo_text)
logging.debug('Repository structure and contents copied to clipboard')
import importlib.util
if importlib.util.find_spec("pyperclip"):
import pyperclip
pyperclip.copy(repo_text)
logging.debug('Repository structure and contents copied to clipboard')
else:
print("Tip: Install 'pyperclip' package to enable automatic clipboard copying:")
print(" pip install pyperclip")
except Exception as e:
logging.warning('Could not copy to clipboard. You might be running this script over SSH or without clipboard support.')
logging.debug(f'Clipboard copy error: {e}')
print(f"[SUCCESS] Repository structure and contents successfully saved to file: \"./{output_file}\"")
return output_file
def create_default_settings_file():

View file

@ -1,6 +1,5 @@
setuptools==70.0.0
pathspec==0.12.1
pytest==8.2.2
argparse==1.4.0
pyperclip==1.8.2
PyYAML==6.0.1
setuptools>=70.0.0
pathspec>=0.12.1
pytest>=8.2.2
argparse>=1.4.0
PyYAML>=6.0.1

View file

@ -5,7 +5,7 @@ with open('requirements.txt') as f:
setup(
name='repo-to-text',
version='0.4.2',
version='0.4.3',
author='Kirill Markin',
author_email='markinkirill@gmail.com',
description='Convert a directory structure and its contents into a single text file, including the tree output and file contents in markdown code blocks. It may be useful to chat with LLM about your code.',