Skip to main content

Search a filesystem using zero or more file and directory filters.

Project description

FSS will recursively scan the given directory for matching files and yield results as a generator. You may provide a list of include/exclude rules for files and/or directories.

The searching is done asynchronously from another process. This way, the searching and whatever you’re doing with the results may potentially run in parallel.

Usage

As Library

Example:

import fss.constants
import fss.config.log
import fss.orchestrator

root_path = '/etc'

filter_rules = [
    (fss.constants.FT_DIR, fss.constants.FILTER_INCLUDE, 'init'),
    (fss.constants.FT_FILE, fss.constants.FILTER_INCLUDE, 'net*'),
    (fss.constants.FT_FILE, fss.constants.FILTER_EXCLUDE, 'networking.conf'),
]

o = fss.orchestrator.Orchestrator(root_path, filter_rules)
for (entry_type, entry_filepath) in o.recurse():
    if entry_type == fss.constants.FT_DIR:
        print("Directory: [%s]" % (entry_filepath,))
    else: # entry_type == fss.constants.FT_FILE:
        print("File: [%s]" % (entry_filepath,))

Output:

Directory: [/etc/init]
File: [/etc/networks]
File: [/etc/netconfig]
File: [/etc/init/network-interface-container.conf]
File: [/etc/init/networking.conf]
File: [/etc/init/network-interface-security.conf]
File: [/etc/init/network-interface.conf]

Notice that even though we only include directories named “init” we’ll still see matching files from the root-path.

As Script

You can also use FSS from the command-line. You’ll get a printout of the results that you can consume and parse.

Example:

$ pathscan -i "i*.h" -id php /usr/include
F /usr/include/iconv.h
F /usr/include/ifaddrs.h
F /usr/include/inttypes.h
F /usr/include/iso646.h
D /usr/include/php

Requirements

  • Python 3.4

Installation

PyPI:

$ sudo pip3 install pathscan

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pathscan-0.2.2.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

pathscan-0.2.2-py2-none-any.whl (14.3 kB view details)

Uploaded Python 2

File details

Details for the file pathscan-0.2.2.tar.gz.

File metadata

  • Download URL: pathscan-0.2.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pathscan-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4846ef754a54ef61077175f06a0bd5efe8d532e4c6ce17236d029acd6cd773ce
MD5 3b55234a5b83a0aa20744cb6573c56dc
BLAKE2b-256 e2beeecc08e2331b6502501261abcbbd1e0145cf9e30d24cb952450d1de53db7

See more details on using hashes here.

File details

Details for the file pathscan-0.2.2-py2-none-any.whl.

File metadata

File hashes

Hashes for pathscan-0.2.2-py2-none-any.whl
Algorithm Hash digest
SHA256 365f1551397989d5ce6f3064ababe3b8dc9d7eff89819f5e96a5c5c86146ef3b
MD5 6aba76ba76a3d585f4d74048c2b74397
BLAKE2b-256 0c76e38d8dd7ee5bae9683ae1bd810e7cce0cd3604c51f18eb121ffc105e8a96

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page