fix: resolve CI/CD issues and linting errors
This commit is contained in:
@@ -1,9 +1,5 @@
|
|||||||
"""Interactive REPL mode for exploring regex patterns."""
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from typing import Optional
|
|
||||||
from .parser import parse_regex
|
|
||||||
from .translator import translate_regex
|
from .translator import translate_regex
|
||||||
from .test_generator import generate_test_cases
|
from .test_generator import generate_test_cases
|
||||||
from .flavors import get_flavor_manager
|
from .flavors import get_flavor_manager
|
||||||
@@ -51,14 +47,14 @@ class InteractiveSession:
|
|||||||
os.makedirs(os.path.dirname(self.history_file), exist_ok=True)
|
os.makedirs(os.path.dirname(self.history_file), exist_ok=True)
|
||||||
with open(self.history_file, 'w') as f:
|
with open(self.history_file, 'w') as f:
|
||||||
for cmd in self.history[-1000:]:
|
for cmd in self.history[-1000:]:
|
||||||
f.write(cmd + '\\n')
|
f.write(cmd + '\n')
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Run the interactive session."""
|
"""Run the interactive session."""
|
||||||
print("\\nRegex Humanizer - Interactive Mode")
|
print("\nRegex Humanizer - Interactive Mode")
|
||||||
print("Type 'help' for available commands, 'quit' to exit.\\n")
|
print("Type 'help' for available commands, 'quit' to exit.\n")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@@ -79,7 +75,7 @@ class InteractiveSession:
|
|||||||
self._process_command(user_input.strip())
|
self._process_command(user_input.strip())
|
||||||
|
|
||||||
except (KeyboardInterrupt, EOFError):
|
except (KeyboardInterrupt, EOFError):
|
||||||
print("\\nGoodbye!")
|
print("\nGoodbye!")
|
||||||
break
|
break
|
||||||
|
|
||||||
def _process_command(self, command: str):
|
def _process_command(self, command: str):
|
||||||
@@ -148,10 +144,10 @@ Examples:
|
|||||||
result = translate_regex(pattern, self.flavor)
|
result = translate_regex(pattern, self.flavor)
|
||||||
|
|
||||||
header = f"Pattern: {pattern}"
|
header = f"Pattern: {pattern}"
|
||||||
print("\\n" + "=" * (len(header)))
|
print("\n" + "=" * (len(header)))
|
||||||
print(header)
|
print(header)
|
||||||
print("=" * (len(header)))
|
print("=" * (len(header)))
|
||||||
print("\\nEnglish Explanation:")
|
print("\nEnglish Explanation:")
|
||||||
print("-" * (len(header)))
|
print("-" * (len(header)))
|
||||||
print(result)
|
print(result)
|
||||||
print()
|
print()
|
||||||
@@ -170,17 +166,17 @@ Examples:
|
|||||||
result = generate_test_cases(pattern, self.flavor, 3, 3)
|
result = generate_test_cases(pattern, self.flavor, 3, 3)
|
||||||
|
|
||||||
header = f"Pattern: {pattern}"
|
header = f"Pattern: {pattern}"
|
||||||
print("\\n" + "=" * (len(header)))
|
print("\n" + "=" * (len(header)))
|
||||||
print(header)
|
print(header)
|
||||||
print("=" * (len(header)))
|
print("=" * (len(header)))
|
||||||
print(f"\\nFlavor: {self.flavor}")
|
print(f"\nFlavor: {self.flavor}")
|
||||||
|
|
||||||
print("\\nMatching strings:")
|
print("\nMatching strings:")
|
||||||
print("-" * (len(header)))
|
print("-" * (len(header)))
|
||||||
for i, s in enumerate(result["matching"], 1):
|
for i, s in enumerate(result["matching"], 1):
|
||||||
print(f" {i}. {s}")
|
print(f" {i}. {s}")
|
||||||
|
|
||||||
print("\\nNon-matching strings:")
|
print("\nNon-matching strings:")
|
||||||
print("-" * (len(header)))
|
print("-" * (len(header)))
|
||||||
for i, s in enumerate(result["non_matching"], 1):
|
for i, s in enumerate(result["non_matching"], 1):
|
||||||
print(f" {i}. {s}")
|
print(f" {i}. {s}")
|
||||||
@@ -266,17 +262,17 @@ Examples:
|
|||||||
def _cmd_example(self, args: str):
|
def _cmd_example(self, args: str):
|
||||||
"""Show an example pattern."""
|
"""Show an example pattern."""
|
||||||
examples = [
|
examples = [
|
||||||
r"^\\d{3}-\\d{4}$",
|
r"^\d{3}-\d{4}$",
|
||||||
r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$",
|
||||||
r"^(?:http|https)://[^\\s]+$",
|
r"^(?:http|https)://[^\s]+$",
|
||||||
r"\\b\\d{4}-\\d{2}-\\d{2}\\b",
|
r"\b\d{4}-\d{2}-\d{2}\b",
|
||||||
r"(?i)(hello|hi|greetings)\\s+world!?",
|
r"(?i)(hello|hi|greetings)\s+world!?",
|
||||||
]
|
]
|
||||||
|
|
||||||
import random
|
import random
|
||||||
example = random.choice(examples)
|
example = random.choice(examples)
|
||||||
print(f"\\nExample pattern: {example}")
|
print(f"\nExample pattern: {example}")
|
||||||
print("\\nType: explain " + example)
|
print("\nType: explain " + example)
|
||||||
print("Type: test " + example)
|
print("Type: test " + example)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user