Skip to content

Commit

Permalink
added get_plugin_details_text_from_file, and changed name of get_plug…
Browse files Browse the repository at this point in the history
…in_text to get_plugin_details_text
  • Loading branch information
midays committed May 30, 2024
1 parent 068c231 commit 7832a02
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/models/IDE/VisualStudioCode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import re
import subprocess
import time

Expand All @@ -9,6 +10,7 @@
from src.models.IDE.VSCodeCommandEnum import VSCodeCommandEnum
from src.utils.general import get_clipboard_text
from src.utils.general import parse_kantra_cli_command
from src.utils.general import read_file

logging.basicConfig(level=logging.DEBUG)

Expand Down Expand Up @@ -213,7 +215,7 @@ def open_plugin_info(self, refocus=False):
if refocus:
self.cmd_palette_open_file()

def get_plugin_text(self):
def get_plugin_details_text(self):
self.close_all_tabs()
self.open_plugin_info()
time.sleep(1)
Expand All @@ -225,6 +227,22 @@ def get_plugin_text(self):
time.sleep(2)
return get_clipboard_text(split=True)

def get_plugin_details_text_from_file(self, readme_file_path):
readme_content = read_file(readme_file_path)
readme_content = re.sub(r"<!--.*?-->", "", readme_content, flags=re.DOTALL)
readme_content = re.sub(r"\[([^\]]+)\]\((https?://[^\)]+)\)", r"\1", readme_content)
readme_content = re.sub(r"!\[([^\]]*)\]\((https?://[^\)]+)\)", r"\1", readme_content)
readme_content = re.sub(r"```[\s\S]*?```", lambda m: m.group(0).replace("```", ""), readme_content)
readme_content = re.sub(r"`([^`]+)`", r"\1", readme_content)
readme_content = re.sub(r"#+\s*", "", readme_content)
readme_content = re.sub(r"^[\*\-\+]\s+", "", readme_content, flags=re.MULTILINE)
readme_content = re.sub(r"^>\s+", "", readme_content, flags=re.MULTILINE)
readme_content = re.sub(r"\n{2,}", "\n\n", readme_content)
readme_content = "\n".join(line.strip() for line in readme_content.splitlines() if line.strip())
readme_content = readme_content.strip()

return readme_content

def focus_problems_panel(self):
"""
Focus on the problems panel
Expand Down

0 comments on commit 7832a02

Please sign in to comment.