From 965771fb0d85ddb27dc6c5dd7df822d1fb318286 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Sat, 15 Mar 2025 16:35:39 +0800 Subject: refactor: clean up code formatting and add new PluginManager class --- examples/basic_usage.py | 8 +++++--- examples/custom_plugin.py | 13 ++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/basic_usage.py b/examples/basic_usage.py index 22bfbe4..7a4e53d 100644 --- a/examples/basic_usage.py +++ b/examples/basic_usage.py @@ -3,10 +3,11 @@ from conventionalrp.core.processor import Processor from conventionalrp.extractors.rule_extractor import RuleExtractor from conventionalrp.renderers.html_renderer import HTMLRenderer + def main(): # Initialize the parser and load rules parser = Parser() - parser.load_rules('path/to/rules.json') + parser.load_rules("path/to/rules.json") # Parse the TRPG log log_data = "Your TRPG log data here" @@ -14,7 +15,7 @@ def main(): # Initialize the rule extractor extractor = RuleExtractor() - rules = extractor.extract('path/to/rules.json') + rules = extractor.extract("path/to/rules.json") # Process the parsed tokens processor = Processor() @@ -27,5 +28,6 @@ def main(): # Print or save the output print(output) + if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/examples/custom_plugin.py b/examples/custom_plugin.py index 5ae6581..ecb9e71 100644 --- a/examples/custom_plugin.py +++ b/examples/custom_plugin.py @@ -1,25 +1,28 @@ from conventionalrp.plugins.plugin_manager import PluginManager + class CustomPlugin: def __init__(self): self.name = "Custom Plugin" - + def process(self, data): # Custom processing logic processed_data = data.upper() # Example transformation return processed_data + def main(): plugin_manager = PluginManager() custom_plugin = CustomPlugin() - + plugin_manager.register_plugin(custom_plugin) - + # Example data to process data = "This is a sample TRPG log." result = custom_plugin.process(data) - + print(f"Processed Data: {result}") + if __name__ == "__main__": - main() \ No newline at end of file + main() -- cgit v1.2.3-70-g09d2