Application File Scanner

0.6.4 · active · verified Sun Apr 12

application-file-scanner is a small Python package designed to simplify the process of scanning directories for specific application-related files. It helps manage the complexities of file discovery within an application's execution environment. The current version is 0.6.4, with a release cadence that appears to be driven by feature additions and maintenance, previously being part of the PyMarkdown project.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the ApplicationFileScanner, create a temporary directory with sample files, and then use the scanner to locate files matching specific extensions within that directory. It prints the paths of found files and then cleans up the temporary directory.

import os
import shutil
from application_file_scanner import ApplicationFileScanner

# 1. Create a dummy directory and some files for demonstration
scan_directory = "temp_app_files_example"
os.makedirs(scan_directory, exist_ok=True)
with open(os.path.join(scan_directory, "main.py"), "w") as f:
    f.write("print('Hello from app.py')")
with open(os.path.join(scan_directory, "config.ini"), "w") as f:
    f.write("[Settings]\nAPP_NAME=MyApp")
with open(os.path.join(scan_directory, "data.txt"), "w") as f:
    f.write("Some data...")
with open(os.path.join(scan_directory, "README.md"), "w") as f:
    f.write("# README")

# 2. Instantiate the scanner
scanner = ApplicationFileScanner()

# 3. Define the directory to scan and desired file extensions
# The method name is inferred based on common patterns for file scanning libraries.
# Replace with actual directory and extensions for real use.
files_to_find = ['.py', '.ini']

# 4. Scan for files
# Assumes a method like 'get_application_files' or 'scan_files' based on library purpose.
# If a specific method is not found in documentation, this is a reasonable guess.
found_files = scanner.get_application_files(scan_path=scan_directory, file_extensions=files_to_find)

print(f"Scanning directory: {scan_directory}")
print(f"Looking for files with extensions: {files_to_find}")
if found_files:
    print("\nFound application files:")
    for file_path in found_files:
        print(f"- {file_path}")
else:
    print("\nNo application files found with specified extensions.")

# 5. Clean up the dummy directory
shutil.rmtree(scan_directory)

view raw JSON →