Skip to main content

fsscan

Quickly scan a directory and yield matching entries, based on patterns and/or entry type.

Status

This project is not maintained anymore !

Requirements

  • Python 3.4+ (Python 3.6+ is preferred)
  • scandir (for Python 3.4)

The module is tested on Python 3.4 to 3.7 (included).

Installation

From PyPI

  • Open a terminal
  • Type pip3 install fsscan
    or pip3 install --user fsscan on Linux

From GitHub

  • Download the archive from GitHub
  • Unzip the archive
  • Open a terminal
  • Move to the directory containing setup.py
  • Type pip3 install .
    or pip3 install --user . on Linux

Usage

From command line

$ python3 -m fsscan

or

$ fsscan
usage: fsscan [-h] [-d directory] [-i] [-r] [-t {f,d,b,FILE,DIR,BOTH}] [-f]
              [patterns [patterns ...]]

Quickly scan a directory and yield matching entries.

positional arguments:
  patterns              Patterns to look for in entries names

optional arguments:
  -h, --help            show this help message and exit
  -d directory          Directory to scan
  -i                    Ignore case
  -r                    Recursive scan
  -t {f,d,b,FILE,DIR,BOTH}
                        Type of entry to return
  -f                    Follow symlinks of directories

From script

Using this directory tree sample

    <temp_dir>
    |-- dir1/
    |   |-- logs/
    |   |   |-- file11.log
    |   |-- file11.py
    |-- dir2/
    |   |-- logs/
    |   |   |-- file21.log
    |   |   |-- file22.log
    |   |-- file21.py
    |   |-- file22.py
    |-- file1.py

Example 1 - without parameters

for entry in fsscan.run(temp_dir):
    print(entry)

Output:

<temp_dir>/dir1
<temp_dir>/dir2
<temp_dir>/file1.py

Example 2 - with parameters

parameters = {
    "patterns": "*LOG*",
    "ignore_case": True,
    "wanted_type": fsscan.DIR_TYPE,
    "recursive": True,
}
for entry in fsscan.run(<temp_dir>, **parameters):
    print(entry)

Output:

<temp_dir>/dir1/logs
<temp_dir>/dir2/logs

: The outputs may differ for you OS

Documentation

run(directory='.',
    patterns=None, ignore_case=True, wanted_type=BOTH_TYPES,
    recursive=False, on_error=None, follow_links=False, callback=None):

Parameters
----------
directory : (str or Path)
    Directory to scan
patterns : (str or sequence of str)
    Patterns to look for in entries names
ignore_case : bool
    Ignore case
wanted_type : int
    Type of entry to return (file, directory or both)
recursive : bool
    Recursive scan
on_error : (None or callable)
    Callable to use when an error occured in scandir
follow_links : bool
    Follow symlinks of directories
callback : (None or callable)
    Callable to use after the scan (e.g. entries cast)

Returns
-------
Generator
    Entries paths as string or callback result

For callbacks, see fsscan/callbacks.py.

Thanks

I would say a big thank you to the people listed below :

Metadata

Release files for fsscan 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for fsscan 0.0.5
File Interpreter ABI Platform Actions
fsscan-0.0.5-py3-none-any.whl Python 3 none any Details for fsscan-0.0.5-py3-none-any.whl

Release files / fsscan-0.0.5-py3-none-any.whl

Download URL fsscan-0.0.5-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e8bb5887b551bd625a21bcc19f730e1772bfd295b54321cc2727c0d97f4fe61
BLAKE2b-256 checksum
How to use checksums
f32c1108228058ff1f8b7b8149b5a9f002f7d02cb6498fd7e7b221407c0d3bd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Security for fsscan 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page