Application File Scanner

raw JSON →
0.6.4 verified Fri May 15 auth: no python

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.

pip install application-file-scanner
cli scan
error ModuleNotFoundError: No module named 'application_file_scanner'
cause The 'application_file_scanner' module is not installed in the Python environment.
fix
Install the module using pip: 'pip install application-file-scanner'.
error ImportError: cannot import name 'FileScanner' from 'application_file_scanner'
cause The 'FileScanner' class does not exist in the 'application_file_scanner' module.
fix
Verify the correct class name and import statement by checking the module's documentation.
error TypeError: 'NoneType' object is not iterable
cause A function in 'application_file_scanner' returned None when an iterable was expected.
fix
Ensure the function returns an iterable object, such as a list or tuple.
error AttributeError: module 'application_file_scanner' has no attribute 'scan_directory'
cause The 'scan_directory' function does not exist in the 'application_file_scanner' module.
fix
Check the module's documentation for the correct function name and usage.
error ValueError: Invalid file path provided
cause An invalid or non-existent file path was passed to a function in 'application_file_scanner'.
fix
Verify that the file path is correct and the file exists before passing it to the function.
breaking The core `ApplicationFileScanner` class was moved out of `PyMarkdown` to become a standalone package (`application-file-scanner`) starting with version 0.6.0. Direct imports from `pymarkdown.application_file_scanner` will no longer work.
fix Update your import statements from `from pymarkdown.application_file_scanner import ApplicationFileScanner` to `from application_file_scanner import ApplicationFileScanner`. Ensure `application-file-scanner` is installed as a direct dependency.
gotcha The `ApplicationFileScanner` is designed to be a lightweight tool. For complex or highly performant file system operations, consider specialized libraries or built-in Python modules like `os.walk` or `pathlib` for more granular control or performance optimizations.
fix Evaluate whether `application-file-scanner` meets your performance and complexity requirements. If not, explore alternatives for advanced use cases.
python os / libc status wheel install import disk mem side effects
3.10 alpine (musl) wheel - 0.10s 18.6M 4.0M clean
3.10 slim (glibc) wheel 1.6s 0.07s 19M 4.0M clean
3.11 alpine (musl) wheel - 0.19s 20.6M 4.7M clean
3.11 slim (glibc) wheel 1.7s 0.16s 21M 4.7M clean
3.12 alpine (musl) wheel - 0.14s 12.4M 4.6M clean
3.12 slim (glibc) wheel 1.6s 0.17s 13M 4.6M clean
3.13 alpine (musl) wheel - 0.13s 12.2M 4.8M clean
3.13 slim (glibc) wheel 1.6s 0.15s 13M 4.8M clean
3.9 alpine (musl) build_error - - - - - -
3.9 slim (glibc) build_error - 1.6s - - - -

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)