diff options
Diffstat (limited to 'src/conventionalrp/core')
| -rw-r--r-- | src/conventionalrp/core/__init__.py | 2 | ||||
| -rw-r--r-- | src/conventionalrp/core/parser.py | 7 | ||||
| -rw-r--r-- | src/conventionalrp/core/processor.py | 15 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/conventionalrp/core/__init__.py b/src/conventionalrp/core/__init__.py index d63b2a9..cc59ba4 100644 --- a/src/conventionalrp/core/__init__.py +++ b/src/conventionalrp/core/__init__.py @@ -1,4 +1,4 @@ # FILE: /trpg-log-processor/trpg-log-processor/src/conventionalrp/core/__init__.py """ This file initializes the core module of the conventionalrp SDK. -"""
\ No newline at end of file +""" diff --git a/src/conventionalrp/core/parser.py b/src/conventionalrp/core/parser.py index 266506b..d5b91da 100644 --- a/src/conventionalrp/core/parser.py +++ b/src/conventionalrp/core/parser.py @@ -2,18 +2,19 @@ import json import re from pathlib import Path + class Parser: def __init__(self): self.rules = [] - def load_rules(self, rules_path : str): + def load_rules(self, rules_path: str): """Load parsing rules.""" if not Path(rules_path).exists(): raise FileNotFoundError(f"No such file or directory: {rules_path} ") with open(rules_path, "r", encoding="utf-8") as f: file_content = f.read() - + rules = json.loads(file_content) # validation rule format @@ -53,4 +54,4 @@ class Parser: else: parsed_data.append({"content": line.strip(), "type": "unknown"}) - return parsed_data
\ No newline at end of file + return parsed_data diff --git a/src/conventionalrp/core/processor.py b/src/conventionalrp/core/processor.py index 40033cf..4e2f573 100644 --- a/src/conventionalrp/core/processor.py +++ b/src/conventionalrp/core/processor.py @@ -17,23 +17,28 @@ class Processor: def generate_output(self, processed_data, format_type): # Implement output generation logic based on format_type - if format_type == 'json': + if format_type == "json": return self.generate_json_output(processed_data) - elif format_type == 'html': + elif format_type == "html": return self.generate_html_output(processed_data) - elif format_type == 'markdown': + elif format_type == "markdown": return self.generate_markdown_output(processed_data) else: raise ValueError("Unsupported format type") def generate_json_output(self, processed_data): import json + return json.dumps(processed_data) def generate_html_output(self, processed_data): # Implement HTML output generation - return "<html><body>" + "".join(f"<p>{data}</p>" for data in processed_data) + "</body></html>" + return ( + "<html><body>" + + "".join(f"<p>{data}</p>" for data in processed_data) + + "</body></html>" + ) def generate_markdown_output(self, processed_data): # Implement Markdown output generation - return "\n".join(f"- {data}" for data in processed_data)
\ No newline at end of file + return "\n".join(f"- {data}" for data in processed_data) |
