Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discuss ADR: Safe File and Plist Handling Functions #892

Open
JamesHabben opened this issue Oct 21, 2024 · 4 comments
Open

Discuss ADR: Safe File and Plist Handling Functions #892

JamesHabben opened this issue Oct 21, 2024 · 4 comments
Assignees

Comments

@JamesHabben
Copy link
Collaborator

Implement Safe File and Plist Handling Functions

Context

Currently, artifact modules handle file opening and plist parsing directly, without consistent error handling. This can lead to module failures that stop the execution of the entire artifact when encountering issues.

Proposal

Implement two new utility functions in ilapfuncs.py:

  1. get_file_content(file_path, binary_mode=False, encoding=None)
  2. get_plist_content(file_path)

These functions will encapsulate file opening and plist parsing operations with proper error handling.

Benefits

  • Improved error handling and logging across all artifact modules
  • Simplified code in individual artifact modules
  • Consistent behavior when encountering file access or parsing issues
  • Easier maintenance and updates to error handling logic

Implementation Details

See attached ADR for full implementation details of both functions.

Discussion Points

  • Are there any other parameters needed for these functions?
  • Should we consider any additional error cases?
  • How should we approach updating existing modules to use these new functions?

Please review and provide feedback on this proposal.

https://github.com/abrignoni/iLEAPP/blob/lava-output/admin/docs/features/file_content_access_architecture.md

@JamesHabben JamesHabben changed the title ADR Discussion: Safe File and Plist Handling Functions Discuss ADR: Safe File and Plist Handling Functions Oct 21, 2024
@JamesHabben
Copy link
Collaborator Author

after chat discussion, sounds like we want to include a safe open function to open ccl data

@Johann-PLW Johann-PLW self-assigned this Nov 18, 2024
@Johann-PLW
Copy link
Collaborator

New functions have been added to get SQLite records, plist file or embedded plist contents.

  • get_sqlite_db_records(path, query)
  • get_plist_content(data)
  • get_plist_file_content(file_path)

The goal is to reduce and simplify code, improve error handling and logging across all artifact modules.

Documentation will be added to ADR: Implement Safe File and Plist Handling Functions file and linked to Updating Modules for Automatic Output Generation.

@abrignoni
Copy link
Owner

abrignoni commented Dec 2, 2024 via email

@Johann-PLW
Copy link
Collaborator

@abrignoni.
I have updated the documentation Updating Modules for Automatic Output Generation with some code examples. Let me know if it is enough.
And if you think these changes really improve module writing, I'll update existing scripts to have even more examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants