Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated methods to fetch plugin details info #146

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading