ctl.plugins.walk_dir
A plugin that lets you traverse a directory and process it's files and sub-directories
Classes
MatchConfig
MatchConfig(confu.schema.core.Schema)
Configuration schema that maps a plugin action to a regex pattern
Class Attributes
- action (
Str): plugin action (method name) - pattern (
Str): regex pattern - plugin (
Str): plugin name
WalkDirPlugin
WalkDirPlugin(ctl.plugins.ExecutablePlugin)
walk directories and process files
Class Attributes
- ConfigSchema (
ConfigSchema Class): Base plugin config schema
Instanced Attributes
These attributes / properties will be available on instances of the class
- debug_info (
dict): holds various debug information - requires_output (
bool=False): does the plugin require an output to be set?
Methods
execute
def execute(self, **kwargs)
Execute the plugin
overrides and calls ExecutablePlugin.execute
ignored
def ignored(self, path, dirpath)
Check if a filepath matches any of the patterns set up
in the ignore config attribute
Argument(s)
- path (
str): relative filepath being processed - dirpath (
str): relative dirpath being processed
Returns
True if file should be ignored, False if not
output
def output(self, path=None)
Returns the output path
Plugin's prepare method needs to have been called.
Keyword Arguments
- path (
str): if specified will join this path to the output path and return the result
Returns
output path (str)
prepare
def prepare(self, **kwargs)
prepare plugin for execution
Output directory
output directory from config.output will be created
if it does not exist
overrides ExecutablePlugin.prepare
prepare_file
def prepare_file(self, path, dirpath)
Prepare a file for processing
Right now this mainly ensures that the output path for the processed file exists by creating it.
Argument(s)
- path (
str): relative filepath being processed - dirpath (
str): relative dirpath being processed
process_file
def process_file(self, path, dirpath)
Test MatchConfig instances set up in the process
config attribute against the provided file path and
process file according to matches.
Argument(s)
- path (
str): relative filepath being processed - dirpath (
str): relative dirpath being processed
process_files
def process_files(self)
Walks the subdirectories of the source path and processes the files.
Only subdirectories specified in the walk_dirs
config attribute will be considered.
source
def source(self, path=None)
Returns the source path
Plugin's prepare method needs to have been called.
Keyword Arguments
- path (
str): if specified will join this path to the source path and return the result
Returns
source path (str)
WalkDirPluginConfig
WalkDirPluginConfig(confu.schema.core.Schema)
Configuration schema for the walkdir plugin
Class Attributes
- debug (
Bool): debug mode - ignore (
List<Str>): regex patterns that if matched will cause a file or directory to be ignored - output (
Str): output directory - process (
List<MatchConfig>): pattern matches to plugin actions - skip_dotfiles (
Bool): Skip dot files - source (
Str): source directory - walk_dirs (
List<Str>): subdirectories to walk and process files in