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