3.4 KiB
3.4 KiB
Plan for Adding .rar and .7z Support
Goal: Extend the Asset Processor Tool to accept .rar and .7z files as input sources, in addition to the currently supported .zip files and folders.
Plan:
-
Add Required Libraries:
- Update the
requirements.txtfile to includepy7zrandrarfileas dependencies. This will ensure these libraries are installed when setting up the project.
- Update the
-
Modify Input Extraction Logic:
- Locate the
_extract_inputmethod within theAssetProcessorclass inasset_processor.py. - Modify this method to check the file extension of the input source.
- If the extension is
.zip, retain the existing extraction logic using Python's built-inzipfilemodule. - If the extension is
.rar, implement extraction using therarfilelibrary. - If the extension is
.7z, implement extraction using thepy7zrlibrary. - Include error handling for cases where the archive might be corrupted, encrypted (since we are not implementing password support at this stage, these should likely be skipped or logged as errors), or uses an unsupported compression method. Log appropriate warnings or errors in such cases.
- If the input is a directory, retain the existing logic to copy its contents to the temporary workspace.
- Locate the
-
Update CLI and Monitor Input Handling:
- Review
main.py(CLI entry point) andmonitor.py(Directory Monitor). - Ensure that the argument parsing in
main.pycan accept.rarand.7zfile paths as valid inputs. - In
monitor.py, modify theZipHandler(or create a new handler) to watch for.rarand.7zfile creation events in the watched directory, in addition to.zipfiles. The logic for triggering processing viamain.run_processingshould then be extended to handle these new file types.
- Review
-
Update Documentation:
- Edit
Documentation/00_Overview.mdto explicitly mention.rarand.7zas supported input formats in the overview section. - Update
Documentation/01_User_Guide/02_Features.mdto list.rarand.7zalongside.zipand folders in the features list. - Modify
Documentation/01_User_Guide/03_Installation.mdto include instructions for installing the newpy7zrandrarfiledependencies (likely viapip install -r requirements.txt). - Revise
Documentation/02_Developer_Guide/05_Processing_Pipeline.mdto accurately describe the updated_extract_inputmethod, detailing how.zip,.rar,.7z, and directories are handled.
- Edit
-
Testing:
- Prepare sample
.rarand.7zfiles (including nested directories and various file types) to test the extraction logic thoroughly. - Test processing of these new archive types via both the CLI and the Directory Monitor.
- Verify that the subsequent processing steps (classification, map processing, metadata generation, etc.) work correctly with files extracted from
.rarand.7zarchives.
- Prepare sample
Here is a simplified flow diagram illustrating the updated input handling:
graph TD
A[Input Source] --> B{Is it a file or directory?};
B -- Directory --> C[Copy Contents to Workspace];
B -- File --> D{What is the file extension?};
D -- .zip --> E[Extract using zipfile];
D -- .rar --> F[Extract using rarfile];
D -- .7z --> G[Extract using py7zr];
E --> H[Temporary Workspace];
F --> H;
G --> H;
C --> H;
H --> I[Processing Pipeline Starts];