kopipasta 0.12.0__py3-none-any.whl → 0.14.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kopipasta might be problematic. Click here for more details.
- kopipasta/main.py +42 -77
- {kopipasta-0.12.0.dist-info → kopipasta-0.14.0.dist-info}/METADATA +1 -1
- kopipasta-0.14.0.dist-info/RECORD +8 -0
- kopipasta-0.12.0.dist-info/RECORD +0 -8
- {kopipasta-0.12.0.dist-info → kopipasta-0.14.0.dist-info}/LICENSE +0 -0
- {kopipasta-0.12.0.dist-info → kopipasta-0.14.0.dist-info}/WHEEL +0 -0
- {kopipasta-0.12.0.dist-info → kopipasta-0.14.0.dist-info}/entry_points.txt +0 -0
- {kopipasta-0.12.0.dist-info → kopipasta-0.14.0.dist-info}/top_level.txt +0 -0
kopipasta/main.py
CHANGED
|
@@ -530,15 +530,26 @@ def process_directory(directory, ignore_patterns, current_char_count=0):
|
|
|
530
530
|
if root in processed_dirs:
|
|
531
531
|
continue
|
|
532
532
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
533
|
+
print(f"\nExploring directory: {root}")
|
|
534
|
+
choice = input("(y)es explore / (n)o skip / (q)uit? ").lower()
|
|
535
|
+
if choice == 'y':
|
|
536
|
+
selected_files, current_char_count = select_files_in_directory(root, ignore_patterns, current_char_count)
|
|
537
|
+
for file_tuple in selected_files:
|
|
538
|
+
if len(file_tuple) == 3:
|
|
539
|
+
f, use_snippet, chunks = file_tuple
|
|
540
|
+
files_to_include.append((os.path.join(root, f), use_snippet, chunks))
|
|
541
|
+
else:
|
|
542
|
+
f, use_snippet = file_tuple
|
|
543
|
+
files_to_include.append((os.path.join(root, f), use_snippet))
|
|
544
|
+
processed_dirs.add(root)
|
|
545
|
+
elif choice == 'n':
|
|
546
|
+
dirs[:] = [] # Skip all subdirectories
|
|
547
|
+
continue
|
|
548
|
+
elif choice == 'q':
|
|
549
|
+
break
|
|
550
|
+
else:
|
|
551
|
+
print("Invalid choice. Skipping this directory.")
|
|
552
|
+
continue
|
|
542
553
|
|
|
543
554
|
return files_to_include, processed_dirs, current_char_count
|
|
544
555
|
|
|
@@ -712,78 +723,37 @@ def main():
|
|
|
712
723
|
env_vars = read_env_file()
|
|
713
724
|
|
|
714
725
|
files_to_include = []
|
|
726
|
+
processed_dirs = set()
|
|
715
727
|
web_contents = {}
|
|
716
|
-
|
|
717
|
-
def process_directory(directory):
|
|
718
|
-
files = [f for f in os.listdir(directory)
|
|
719
|
-
if os.path.isfile(os.path.join(directory, f)) and not is_ignored(os.path.join(directory, f), ignore_patterns) and not is_binary(os.path.join(directory, f))]
|
|
720
|
-
|
|
721
|
-
if not files:
|
|
722
|
-
return []
|
|
723
|
-
|
|
724
|
-
print(f"\nDirectory: {directory}")
|
|
725
|
-
print("Files:")
|
|
726
|
-
for file in files:
|
|
727
|
-
file_path = os.path.join(directory, file)
|
|
728
|
-
file_size = os.path.getsize(file_path)
|
|
729
|
-
file_size_readable = get_human_readable_size(file_size)
|
|
730
|
-
print(f"- {file} ({file_size_readable})")
|
|
731
|
-
|
|
732
|
-
while True:
|
|
733
|
-
choice = input("(y)es add all / (n)o ignore all / (s)elect individually / (q)uit? ").lower()
|
|
734
|
-
if choice == 'y':
|
|
735
|
-
return [(os.path.join(directory, f), False) for f in files]
|
|
736
|
-
elif choice == 'n':
|
|
737
|
-
return []
|
|
738
|
-
elif choice == 's':
|
|
739
|
-
selected_files = []
|
|
740
|
-
for file in files:
|
|
741
|
-
file_path = os.path.join(directory, file)
|
|
742
|
-
while True:
|
|
743
|
-
file_choice = input(f"{file} (y/n/p/q)? ").lower()
|
|
744
|
-
if file_choice == 'y':
|
|
745
|
-
selected_files.append((file_path, False))
|
|
746
|
-
break
|
|
747
|
-
elif file_choice == 'n':
|
|
748
|
-
break
|
|
749
|
-
elif file_choice == 'p':
|
|
750
|
-
chunks, _ = select_file_patches(file_path)
|
|
751
|
-
if chunks:
|
|
752
|
-
selected_files.append((file_path, True, chunks))
|
|
753
|
-
break
|
|
754
|
-
elif file_choice == 'q':
|
|
755
|
-
return selected_files
|
|
756
|
-
else:
|
|
757
|
-
print("Invalid choice. Please enter 'y', 'n', 'p', or 'q'.")
|
|
758
|
-
return selected_files
|
|
759
|
-
elif choice == 'q':
|
|
760
|
-
return []
|
|
761
|
-
else:
|
|
762
|
-
print("Invalid choice. Please try again.")
|
|
728
|
+
current_char_count = 0
|
|
763
729
|
|
|
764
730
|
for input_path in args.inputs:
|
|
765
731
|
if input_path.startswith(('http://', 'https://')):
|
|
766
|
-
|
|
767
|
-
if
|
|
768
|
-
|
|
769
|
-
|
|
732
|
+
full_content, snippet = fetch_web_content(input_path)
|
|
733
|
+
if full_content:
|
|
734
|
+
web_contents[input_path] = (full_content, snippet)
|
|
735
|
+
current_char_count += len(snippet if len(full_content) > 10000 else full_content)
|
|
770
736
|
print(f"Added web content from: {input_path}")
|
|
771
737
|
elif os.path.isfile(input_path):
|
|
772
738
|
if not is_ignored(input_path, ignore_patterns) and not is_binary(input_path):
|
|
773
739
|
while True:
|
|
774
740
|
file_choice = input(f"{input_path} (y)es include / (n)o skip / (p)atches / (q)uit? ").lower()
|
|
775
741
|
if file_choice == 'y':
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
742
|
+
use_snippet = is_large_file(input_path)
|
|
743
|
+
files_to_include.append((input_path, use_snippet))
|
|
744
|
+
if use_snippet:
|
|
745
|
+
current_char_count += len(get_file_snippet(input_path))
|
|
746
|
+
else:
|
|
747
|
+
current_char_count += os.path.getsize(input_path)
|
|
748
|
+
print(f"Added file: {input_path}{' (snippet)' if use_snippet else ''}")
|
|
780
749
|
break
|
|
781
750
|
elif file_choice == 'n':
|
|
782
751
|
break
|
|
783
752
|
elif file_choice == 'p':
|
|
784
|
-
chunks,
|
|
753
|
+
chunks, char_count = select_file_patches(input_path)
|
|
785
754
|
if chunks:
|
|
786
|
-
files_to_include.append((input_path,
|
|
755
|
+
files_to_include.append((input_path, False, chunks))
|
|
756
|
+
current_char_count += char_count
|
|
787
757
|
break
|
|
788
758
|
elif file_choice == 'q':
|
|
789
759
|
print("Quitting.")
|
|
@@ -793,16 +763,9 @@ def main():
|
|
|
793
763
|
else:
|
|
794
764
|
print(f"Ignored file: {input_path}")
|
|
795
765
|
elif os.path.isdir(input_path):
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
file_path, use_snippet = file_info
|
|
800
|
-
content, content_type = read_file_content(file_path)
|
|
801
|
-
content, is_snippet = handle_content(content, content_type, file_path)
|
|
802
|
-
files_to_include.append((file_path, content, is_snippet, content_type))
|
|
803
|
-
else:
|
|
804
|
-
file_path, _, chunks = file_info
|
|
805
|
-
files_to_include.append((file_path, None, False, 'text', chunks))
|
|
766
|
+
dir_files, dir_processed, current_char_count = process_directory(input_path, ignore_patterns, current_char_count)
|
|
767
|
+
files_to_include.extend(dir_files)
|
|
768
|
+
processed_dirs.update(dir_processed)
|
|
806
769
|
else:
|
|
807
770
|
print(f"Warning: {input_path} is not a valid file, directory, or URL. Skipping.")
|
|
808
771
|
|
|
@@ -811,7 +774,8 @@ def main():
|
|
|
811
774
|
return
|
|
812
775
|
|
|
813
776
|
print("\nFile and web content selection complete.")
|
|
814
|
-
|
|
777
|
+
print_char_count(current_char_count)
|
|
778
|
+
print(f"Summary: Added {len(files_to_include)} files from {len(processed_dirs)} directories and {len(web_contents)} web sources.")
|
|
815
779
|
|
|
816
780
|
prompt = generate_prompt(files_to_include, ignore_patterns, web_contents, env_vars)
|
|
817
781
|
print("\n\nGenerated prompt:")
|
|
@@ -822,6 +786,7 @@ def main():
|
|
|
822
786
|
pyperclip.copy(prompt)
|
|
823
787
|
separator = "\n" + "=" * 40 + "\n☕🍝 Kopipasta Complete! 🍝☕\n" + "=" * 40 + "\n"
|
|
824
788
|
print(separator)
|
|
789
|
+
final_char_count = len(prompt)
|
|
825
790
|
final_token_estimate = final_char_count // 4
|
|
826
791
|
print(f"Prompt has been copied to clipboard. Final size: {final_char_count} characters (~ {final_token_estimate} tokens)")
|
|
827
792
|
except pyperclip.PyperclipException as e:
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
kopipasta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
kopipasta/main.py,sha256=xoH5I0vAbKbz51trNtqItc-d72s2J2f9b7dIKTTFSCE,31094
|
|
3
|
+
kopipasta-0.14.0.dist-info/LICENSE,sha256=xw4C9TAU7LFu4r_MwSbky90uzkzNtRwAo3c51IWR8lk,1091
|
|
4
|
+
kopipasta-0.14.0.dist-info/METADATA,sha256=onX0C9YmxAPItIrKTlJfoSggPPKZJNs-M1bGaXIlCTY,5646
|
|
5
|
+
kopipasta-0.14.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
6
|
+
kopipasta-0.14.0.dist-info/entry_points.txt,sha256=but54qDNz1-F8fVvGstq_QID5tHjczP7bO7rWLFkc6Y,50
|
|
7
|
+
kopipasta-0.14.0.dist-info/top_level.txt,sha256=iXohixMuCdw8UjGDUp0ouICLYBDrx207sgZIJ9lxn0o,10
|
|
8
|
+
kopipasta-0.14.0.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
kopipasta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
kopipasta/main.py,sha256=ANbRa5aUs33pNijS8c9PDnROLYDY_AszRHHMVd0v7tM,32821
|
|
3
|
-
kopipasta-0.12.0.dist-info/LICENSE,sha256=xw4C9TAU7LFu4r_MwSbky90uzkzNtRwAo3c51IWR8lk,1091
|
|
4
|
-
kopipasta-0.12.0.dist-info/METADATA,sha256=YOtx67yMFdORrPVgKoyhGEKWGew9yR3mjzH7Fjl6BYM,5646
|
|
5
|
-
kopipasta-0.12.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
6
|
-
kopipasta-0.12.0.dist-info/entry_points.txt,sha256=but54qDNz1-F8fVvGstq_QID5tHjczP7bO7rWLFkc6Y,50
|
|
7
|
-
kopipasta-0.12.0.dist-info/top_level.txt,sha256=iXohixMuCdw8UjGDUp0ouICLYBDrx207sgZIJ9lxn0o,10
|
|
8
|
-
kopipasta-0.12.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|