Support for converting HTML results into text [GH-1]#14
Conversation
Development fixes
Development fixes
…d fixing as it has permission denied error.
Report parsing [GH-1]
Reviewer's Guide by SourceryThis pull request introduces a new lookup plugin, Sequence diagram for parsing MT5 report and converting to CSVsequenceDiagram
participant Ansible
participant parse_mt_report.py
participant MT5 Report (HTML)
participant CSV File
Ansible->>parse_mt_report.py: lookup('parse_mt_report', report_path, report_type, include_titles)
activate parse_mt_report.py
parse_mt_report.py->>MT5 Report (HTML): Read HTML content
MT5 Report (HTML)-->>parse_mt_report.py: HTML content
alt report_type is 'header'
parse_mt_report.py->>parse_mt_report.py: Extract header table
parse_mt_report.py->>parse_mt_report.py: Convert header table to JSON
parse_mt_report.py-->>Ansible: JSON string
else report_type is 'orders' or 'deals'
parse_mt_report.py->>parse_mt_report.py: Extract orders/deals table
parse_mt_report.py->>parse_mt_report.py: Convert table to CSV
parse_mt_report.py-->>Ansible: CSV string
else report_type is 'opt'
parse_mt_report.py->>parse_mt_report.py: Parse XML to extract optimization data
parse_mt_report.py->>parse_mt_report.py: Convert optimization data to CSV
parse_mt_report.py-->>Ansible: CSV string
end
deactivate parse_mt_report.py
Ansible->>CSV File: Write CSV string to file
Class diagram for parse_mt_report.pyclassDiagram
class LookupModule {
+run(terms, variables, **kwargs)
}
class main {
+main(input_file_path, output_file_path, include_titles, type, return_string)
}
class write_to_csv {
+write_to_csv(data, output_file, include_titles, type, return_string)
}
class write_to_json {
+write_to_json(html_content, output_file, type, return_string)
}
class write_opt {
+write_opt(input_file, output_file, include_titles, return_string)
}
class extract_header_table {
+extract_header_table(html_content)
}
class extract_orders_table {
+extract_orders_table(html_content)
}
class extract_deals_table {
+extract_deals_table(html_content)
}
class parse_period {
+parse_period(value)
}
class parse_val_prc {
+parse_val_prc(value)
}
class parse_prc_val {
+parse_prc_val(value)
}
class parse_val_of {
+parse_val_of(value)
}
class parse_val_diff {
+parse_val_diff(value)
}
class parse_time {
+parse_time(value)
}
class convert_value {
+convert_value(value)
}
LookupModule -- main : calls
main -- write_to_csv : calls
main -- write_to_json : calls
main -- write_opt : calls
write_to_csv -- extract_orders_table : calls
write_to_csv -- extract_deals_table : calls
write_to_json -- extract_header_table : calls
extract_header_table -- parse_period : calls
extract_header_table -- parse_val_prc : calls
extract_header_table -- parse_prc_val : calls
extract_header_table -- parse_val_of : calls
extract_header_table -- parse_val_diff : calls
extract_header_table -- parse_time : calls
extract_header_table -- convert_value : calls
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Hello @kenorb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request introduces a new lookup plugin, parse_mt_report.py, to convert HTML reports generated by MetaTrader (MT4/MT5) into structured data formats like CSV and JSON. It also adds tasks to the main.yml file to utilize this plugin and generate CSV files from the MT5 reports for Orders, Deals, Header, and Optimization data. The primary goal is to automate the extraction of data from these reports for further analysis or integration.
Highlights
- New Lookup Plugin: The
parse_mt_report.pyplugin is introduced to parse MetaTrader HTML reports. It usesBeautifulSoupfor HTML parsing and regular expressions to extract specific data points. - Data Extraction: The plugin extracts data from different sections of the HTML report, including header information, order details, deal records, and optimization results.
- Output Formatting: The extracted data can be formatted into CSV or JSON. The
main.ymlfile uses the plugin to generate CSV files for different report sections. - Ansible Integration: The plugin is designed as an Ansible lookup module, allowing it to be used directly within Ansible playbooks to process report files.
Changelog
Click here to see the changelog
- lookup_plugins/parse_mt_report.py
- Initial commit of the
parse_mt_report.pylookup plugin. - Implements functions to parse different sections of the HTML report:
extract_header_table,extract_orders_table,extract_deals_table. - Includes functions to write data to CSV (
write_to_csv) and JSON (write_to_json). - Adds helper functions for data conversion and parsing specific value formats (e.g.,
parse_period,parse_val_prc). - Defines the
LookupModuleclass to integrate the plugin with Ansible. - Adds main function to orchestrate the parsing and writing processes based on the specified type (orders, deals, header, opt).
- Initial commit of the
- tasks/main.yml
- Adds new tasks to convert MT5 reports to CSV format using the
parse_mt_reportlookup plugin. - Creates separate tasks for converting Orders, Deals, Header, and Optimization data to CSV files.
- Uses the
copymodule to write the CSV content to files with specific names based on the report type. - Specifies
become: trueandbecome_user: rootfor these tasks.
- Adds new tasks to convert MT5 reports to CSV format using the
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Did you know?
The term 'plugin' comes from the world of hardware, where physical components could be 'plugged in' to extend a system's capabilities.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
The pull request introduces a new lookup plugin to parse MetaTrader reports and convert them into CSV format. It also includes changes to the default timeout value and adds tasks to generate CSV reports for orders, deals, headers, and optimization results. Overall, the changes seem well-structured and address the intended functionality.
Merge Readiness
The changes introduced by this pull request seem well-structured and address the intended functionality. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging. Given the absence of CRITICAL or HIGH severity issues, the pull request appears to be in good shape for merging.
There was a problem hiding this comment.
Hey @kenorb - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider using a loop in your tasks file to avoid repeating the same task multiple times.
- The lookup plugin has a lot of code - consider breaking it up into smaller functions or classes.
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…ify-len-comparison) Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Use named expression to simplify assignment and conditional (use-named-expression) Remove unnecessary else after guard condition (remove-unnecessary-else) Replace m.group(x) with m[x] for re.Match objects [×3] (use-getitem-for-re-match-groups) Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
- Use named expression to simplify assignment and conditional (use-named-expression) - Remove unnecessary else after guard condition (remove-unnecessary-else) - Replace m.group(x) with m[x] for re.Match objects [×2] (use-getitem-for-re-match-groups) Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Refs #14: Fixes problem with Windows commands under Unix
* dev: Refactor devcontainer and Dependabot configuration for clarity and consistency Fix indentation in Dependabot configuration for devcontainers Add .ansible to .gitignore Add Dependabot configuration for weekly devcontainer updates Add GitHub Copilot extensions to devcontainer configuration Add devcontainer configuration for Ansible role development
… and improve readability
…missing dependencies
5de66f9 to
e5f88b0
Compare
…sible-lint and yamllint
…t for failure conditions
* origin/dev: Sets oneline as default Ansible screen output [no-ci] Sets metatrader to v1.0.1 version Increases timeout to 120 Adds code-review.prompt.md [no-ci] Improves molecule provisioner config options Adds paths-ignore for molecule workflow Improves molecule test report Updates pre-commit/action to v3.0.1 Updates devcontainer.json Corrects copilot-instructions.md Ignores *.html files Adds .markdownlint.yaml Updates Pipfile.lock [no-ci] Updates requirements.txt Removes redundant requirements files Updates requirements file [no-ci] Adds Pipfile and lock file [no-ci] Removes meta/requirements.txt [no-ci] Update molecule workflow to enable debug mode conditionally on failure Adds vscode-github-actions extension
… for terminal errors
…result_format settings
… in molecule.yml for enhanced logging
…platforms. Fixes MT4 config load logic.
Fixes GH-1.
Summary by Sourcery
Adds the ability to convert MetaTrader HTML reports into CSV format for orders, deals, and header information, and also supports converting optimization reports.
New Features:
Tests: