-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_for_gpt.py
33 lines (28 loc) · 1013 Bytes
/
copy_for_gpt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
def read_and_format_files(filenames):
output = ""
for filename in filenames:
try:
with open(filename, 'r') as file:
content = file.read()
output += f"{filename}:\n{content}\n\n"
except FileNotFoundError:
output += f"{filename}: File not found\n\n"
except Exception as e:
output += f"{filename}: An error occurred - {str(e)}\n\n"
return output
def copy_to_clipboard(text):
""" Copy given text to system clipboard. """
try:
with os.popen('pbcopy', 'w') as clipboard:
clipboard.write(text)
clipboard.close()
print("Content copied to clipboard.")
except Exception as e:
print(f"Failed to copy content to clipboard: {str(e)}")
def main():
files = ["content.js", "manifest.json", "popup.js", "popup.html"]
formatted_output = read_and_format_files(files)
copy_to_clipboard(formatted_output)
if __name__ == "__main__":
main()