kopipasta 0.17.0__py3-none-any.whl → 0.18.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 CHANGED
@@ -8,11 +8,22 @@ import re
8
8
  from typing import Dict, List, Optional, Set, Tuple
9
9
  import pyperclip
10
10
  import fnmatch
11
+ from pygments import highlight
12
+ from pygments.lexers import get_lexer_for_filename, TextLexer
13
+ from pygments.formatters import TerminalFormatter
14
+ import pygments.util
11
15
 
12
16
  import requests
13
17
 
14
18
  FileTuple = Tuple[str, bool, Optional[List[str]], str]
15
19
 
20
+ def get_colored_code(file_path, code):
21
+ try:
22
+ lexer = get_lexer_for_filename(file_path)
23
+ except pygments.util.ClassNotFound:
24
+ lexer = TextLexer()
25
+ return highlight(code, lexer, TerminalFormatter())
26
+
16
27
  def read_gitignore():
17
28
  default_ignore_patterns = [
18
29
  '.git', 'node_modules', 'venv', '.venv', 'dist', '.idea', '__pycache__',
@@ -375,7 +386,8 @@ def select_file_patches(file_path):
375
386
  print(f"\nSelecting patches for {file_path}")
376
387
  for index, (chunk_code, start_line, end_line) in enumerate(code_chunks):
377
388
  print(f"\nChunk {index + 1} (Lines {start_line + 1}-{end_line}):")
378
- print(f"```{language}\n{chunk_code}\n```")
389
+ colored_chunk = get_colored_code(file_path, chunk_code)
390
+ print(colored_chunk)
379
391
  while True:
380
392
  choice = input("(y)es include / (n)o skip / (q)uit rest of file? ").lower()
381
393
  if choice == 'y':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kopipasta
3
- Version: 0.17.0
3
+ Version: 0.18.0
4
4
  Summary: A CLI tool to generate prompts with project structure and file contents
5
5
  Home-page: https://github.com/mkorpela/kopipasta
6
6
  Author: Mikko Korpela
@@ -0,0 +1,8 @@
1
+ kopipasta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ kopipasta/main.py,sha256=VuVUOjCL1XeAV9u7oo-hx2v42KgE0mFYWzfoDn2hL6E,35090
3
+ kopipasta-0.18.0.dist-info/LICENSE,sha256=xw4C9TAU7LFu4r_MwSbky90uzkzNtRwAo3c51IWR8lk,1091
4
+ kopipasta-0.18.0.dist-info/METADATA,sha256=be12_mfA2Ivg30CH8gIVrghmVzz71-56nAanX7ZsZhM,5646
5
+ kopipasta-0.18.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
6
+ kopipasta-0.18.0.dist-info/entry_points.txt,sha256=but54qDNz1-F8fVvGstq_QID5tHjczP7bO7rWLFkc6Y,50
7
+ kopipasta-0.18.0.dist-info/top_level.txt,sha256=iXohixMuCdw8UjGDUp0ouICLYBDrx207sgZIJ9lxn0o,10
8
+ kopipasta-0.18.0.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- kopipasta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- kopipasta/main.py,sha256=jDcsdCYE3u2EuMKZbcpkyayxgj5soLLm7XWbhG46Poo,34657
3
- kopipasta-0.17.0.dist-info/LICENSE,sha256=xw4C9TAU7LFu4r_MwSbky90uzkzNtRwAo3c51IWR8lk,1091
4
- kopipasta-0.17.0.dist-info/METADATA,sha256=4JjrjvjRucGOIlIEP3PvPDLefJ-Dq7JTDGd1HIbiraA,5646
5
- kopipasta-0.17.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
6
- kopipasta-0.17.0.dist-info/entry_points.txt,sha256=but54qDNz1-F8fVvGstq_QID5tHjczP7bO7rWLFkc6Y,50
7
- kopipasta-0.17.0.dist-info/top_level.txt,sha256=iXohixMuCdw8UjGDUp0ouICLYBDrx207sgZIJ9lxn0o,10
8
- kopipasta-0.17.0.dist-info/RECORD,,