### GET / - Main Index Page Source: https://context7.com/beastopc/autoreview/llms.txt Serves the main upload form interface where users can specify folder names, previous companies to search for, select files/folders to upload, and choose an import action. ```APIDOC ## GET / ### Description Serves the main upload form interface where users can specify folder names, previous companies to search for, select files/folders to upload, and choose an import action. ### Method GET ### Endpoint / ### Parameters None ### Request Example None ### Response #### Success Response (200) - Renders the main upload form (HTML). #### Response Example (HTML content for the form) ``` -------------------------------- ### Extract File Metadata to CSV using Bash and Exiftool Source: https://context7.com/beastopc/autoreview/llms.txt This script uses exiftool to recursively extract metadata from all files in a specified folder and exports the results to a CSV file. It requires exiftool to be installed. ```bash #!/bin/sh foldername=$1 timestamp=$2 echo "The folder is called $foldername" results_file="/code/${foldername}_${timestamp}/metadata.csv" cd "/code/${foldername}_${timestamp}" # Extract all metadata recursively and export to CSV exiftool -csv -r -All . >> "$results_file" echo "Metadata output saved to $results_file" # Example usage: # ./file_metadata.sh project_review 01152024_1430 # Output: metadata.csv containing columns like: # SourceFile,FileSize,FileType,CreateDate,ModifyDate,Author,Title,... ``` -------------------------------- ### GET /upload_status - Upload Status Page Source: https://context7.com/beastopc/autoreview/llms.txt Displays the results of grep searches and processing status after file uploads are complete. ```APIDOC ## GET /upload_status ### Description Displays the results of grep searches and processing status after file uploads are complete. ### Method GET ### Endpoint /upload_status ### Parameters None ### Request Example ```bash curl http://localhost:5001/upload_status ``` ### Response #### Success Response (200) - Renders the upload status page (HTML), which may include grep search results and processing status. #### Response Example (HTML content for the status page) ``` -------------------------------- ### Configure Docker Container for File Processing Source: https://context7.com/beastopc/autoreview/llms.txt This Dockerfile sets up an Alpine Linux environment with necessary tools like exiftool, Python 3, pip, and openpyxl for file processing and metadata extraction. It copies project files into the container and sets the default command to run the Python application. ```dockerfile FROM alpine:latest RUN apk update && \ apk add nmap exiftool sed gawk grep python3 py3-pip && \ pip install openpyxl RUN pip install flask COPY . /app COPY ./templates /app COPY ./code /app WORKDIR app RUN chmod +x file_import.sh RUN chmod +x file_metadata.sh CMD ["python", "app.py"] # Build and run: # docker build -t file-importer . # docker run -p 5001:5001 -v /local/code:/code file-importer # Access the application: # http://localhost:5001 ``` -------------------------------- ### file_import.sh - File Import with Grep Search Source: https://context7.com/beastopc/autoreview/llms.txt Processes uploaded files by searching for terms defined in the dictionary file and outputs matches to a results file. ```APIDOC ## file_import.sh ### Description Processes uploaded files by searching for terms defined in the dictionary file and outputs matches to a results file. It creates a timestamped folder if it doesn't exist and searches each file within the specified folder for terms found in the 'dict' file. ### Method Shell Script (executed via POST /submit) ### Endpoint N/A (Shell script) ### Parameters #### Script Arguments - **foldername** (string) - Required - The base name of the folder to process. ### Request Example (from POST /submit) When `action` is 'file_import', this script is invoked with the `foldername` provided in the form data. ### Response #### Standard Output - "Folder not found: [foldername]" if the folder does not exist. - "Dict file not found: [path/to/dict]" if the dictionary file is missing. - "No results found" if no matches are found. - "Results saved to [path/to/results_file]" upon successful completion. #### Output File - **grep_results.txt**: Contains the results of the grep search, with each line in the format "filename:line_number:matched_line". ### Example Usage ```bash ./file_import.sh project_review ``` ``` -------------------------------- ### POST /submit - File Upload and Processing Endpoint Source: https://context7.com/beastopc/autoreview/llms.txt Handles file uploads with timestamped folder organization and triggers the appropriate import script based on the selected action. Supports file import, code import, combined import, and metadata search operations. ```APIDOC ## POST /submit ### Description Handles file uploads with timestamped folder organization and triggers the appropriate import script based on the selected action. Supports file import, code import, combined import, and metadata search operations. ### Method POST ### Endpoint /submit ### Parameters #### Form Data Parameters - **foldername** (string) - Required - The base name for the timestamped folder. - **prev_companies** (string) - Optional - A newline-separated list of company names to search for (stored in a 'dict' file). - **action** (string) - Required - The action to perform (e.g., 'file_import', 'search_metadata'). - **file** (file) - Required - One or more files to upload. ### Request Example ```bash curl -X POST http://localhost:5001/submit \ -F "foldername=project_review" \ -F "prev_companies=CompanyA\nCompanyB\nCompanyC" \ -F "action=file_import" \ -F "file=@/path/to/document.pdf" \ -F "file=@/path/to/spreadsheet.xlsx" ``` ### Response #### Success Response (200) - Returns a success message upon successful processing (e.g., "Files uploaded successfully", "File metadata search initiated"). #### Error Response - Returns an error message if required parameters are missing or invalid (e.g., "Please enter a folder name", "No file part", "No selected file", "Invalid action"). #### Response Example "Files uploaded successfully" ``` -------------------------------- ### Flask Main Index Page Route Source: https://context7.com/beastopc/autoreview/llms.txt This Python Flask route serves the main upload form interface. It renders the 'index.html' template, allowing users to input folder names, search terms, select files, and choose an import action. ```python from flask import Flask, render_template app = Flask(__name__) @app.route('/') def index(): return render_template('index.html') # Access the main page # curl http://localhost:5001/ ``` -------------------------------- ### Shell Script for File Import and Grep Search Source: https://context7.com/beastopc/autoreview/llms.txt This Bash script processes uploaded files by searching for terms defined in a dictionary file and outputs matches to a results file. It verifies the existence of the target folder and dictionary file before performing the grep operation. ```bash #!/bin/bash foldername=$1 current_date=$(date +%m%d%Y_%H%M) # Add timestamp to folder name foldername="$foldername"_"$current_date" folder_path="/code/$foldername" grep_file="/code/$foldername/dict" results_file="/code/$foldername/grep_results.txt" # Verify folder exists if [ ! -d "$folder_path" ]; then echo "Folder not found: $foldername" exit 1 fi # Verify dictionary file exists if [ ! -f "$grep_file" ]; then echo "Dict file not found: $grep_file" exit 1 fi touch $results_file # Search each file for dictionary terms while IFS= read -r line; do for file in $folder_path/*; do if [ -f "$file" ]; then grep -Hn "$line" "$file" >> "$results_file" fi done done < "$grep_file" if [ ! -s "$results_file" ]; then echo "No results found" exit 1 fi echo "Results saved to $results_file" # Example usage: # ./file_import.sh project_review # Output: grep_results.txt with format "filename:line_number:matched_line" ``` -------------------------------- ### Flask File Upload and Processing Endpoint Source: https://context7.com/beastopc/autoreview/llms.txt This Python Flask route handles file uploads, organizes them into timestamped folders, and triggers import scripts. It supports file import, code import, combined import, and metadata search operations based on user selections. ```python import os import datetime from flask import Flask, request app = Flask(__name__) @app.route('/submit', methods=['POST']) def submit(): action = request.form.get('action') folder_name = request.form.get('foldername') if not folder_name: return "Please enter a folder name" if 'file' not in request.files: return "No file part" files = request.files.getlist('file') if not files: return "No selected file" # Create timestamped folder now = datetime.datetime.now() timestamp = now.strftime("%m%d%Y_%H%M") user_folder = os.path.join('/code', f'{folder_name}_{timestamp}') if not os.path.exists(user_folder): os.makedirs(user_folder) # Save uploaded files for file in files: file.save(os.path.join(user_folder, file.filename)) # Save search terms dictionary previous_companies = request.form.get('prev_companies') if previous_companies: with open(os.path.join(user_folder, 'dict'), 'w') as f: f.write(previous_companies) # Execute appropriate action if action == 'file_import': os.system(f'./file_import.sh {folder_name}') return "Files uploaded successfully" elif action == 'search_metadata': os.system(f'./file_metadata.sh {folder_name} {timestamp}') return "File metadata search initiated" return "Invalid action" # Example curl request to upload files # curl -X POST http://localhost:5001/submit \ # -F "foldername=project_review" \ # -F "prev_companies=CompanyA\nCompanyB\nCompanyC" \ # -F "action=file_import" \ # -F "file=@/path/to/document.pdf" \ # -F "file=@/path/to/spreadsheet.xlsx" ``` -------------------------------- ### Flask Upload Status Page Route Source: https://context7.com/beastopc/autoreview/llms.txt This Python Flask route displays the results of grep searches and the processing status after file uploads. It renders the 'upload_status.html' template to show the outcome of the operations. ```python from flask import Flask, render_template app = Flask(__name__) @app.route('/upload_status') def upload_status(): return render_template('upload_status.html') # View upload status # curl http://localhost:5001/upload_status ``` -------------------------------- ### Detect External Excel Links using Python and Openpyxl Source: https://context7.com/beastopc/autoreview/llms.txt This Python script scans directories for Excel files (.xlsx, .xlsm) and identifies any external file links within their worksheets. It utilizes the openpyxl library and outputs the findings to a CSV file. Dependencies include 'openpyxl'. ```python import os import csv from openpyxl import load_workbook def check_linked_excel_files(path): """Scan for Excel files and detect external links.""" results = [] for dirpath, dirnames, filenames in os.walk(path): for filename in filenames: if filename.endswith('.xlsx') or filename.endswith('.xlsm'): file_path = os.path.join(dirpath, filename) wb = load_workbook(file_path, read_only=True) linked_files = [] for sheet in wb.worksheets: for name, link in sheet.external_links.items(): if link.Target.endswith('.xlsx') or link.Target.endswith('.xlsm'): linked_files.append(link.Target) if linked_files: results.append((file_path, ';'.join(linked_files))) return results def save_results_to_csv(results, output_file): """Export linked file analysis to CSV.""" with open(output_file, 'w', newline='') as f: writer = csv.writer(f) writer.writerow(['File Path', 'Linked Excel Files']) writer.writerows(results) # Example usage: results = check_linked_excel_files('/code/project_review_01152024_1430') save_results_to_csv(results, 'excel_links_report.csv') # Output CSV format: # File Path,Linked Excel Files # /code/project/budget.xlsx,../shared/rates.xlsx;../data/lookup.xlsx # /code/project/report.xlsm,./source_data.xlsx ``` -------------------------------- ### Style File and Code Importer UI Source: https://github.com/beastopc/autoreview/blob/main/app/templates/index.html CSS styles for the File and Code Importer interface, providing a clean, centered layout with custom form controls and button hover states. ```css body { background-color: #f8f9fa; } .container { margin-top: 50px; background-color: #fff; border-radius: 10px; padding: 30px; box-shadow: 0px 0px 10px #ccc; } h1 { color: #007bff; text-align: center; font-weight: bold; margin-bottom: 30px; } label { font-weight: bold; color: #333; } .btn-primary { background-color: #007bff; border-color: #007bff; } .btn-primary:hover { background-color: #0062cc; border-color: #0062cc; } .form-control { background-color: #f8f9fa; color: #333; border: none; } .form-control:focus { background-color: #f8f9fa; color: #333; box-shadow: none; } .custom-file-label { color: #333; } ``` -------------------------------- ### Display Selected File Count Source: https://github.com/beastopc/autoreview/blob/main/app/templates/index.html A JavaScript function that updates the UI to show the number of files selected by the user in an input element. It checks for the existence of files and updates the 'fileCount' DOM element accordingly. ```javascript function displayFileCount(input) { if (input.files && input.files.length > 0) { const fileCount = input.files.length; document.getElementById("fileCount").innerHTML = `Total files: ${fileCount}`; } else { document.getElementById("fileCount").innerHTML = ""; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.