tl.rename.cli

Functions

tl.rename.cli.rename(**defaults)
tl.rename.cli.sys_exit(exception, exit_code)

Classes

class tl.rename.cli.OptionParser(defaults={}, **kwargs)

Bases: optparse.OptionParser

An option parser specialised for the rename executable.

This is a class of its own in order to make it reusable.

add_option(*args, **kwargs)

add_option(Option) add_option(opt_str, ..., kwarg=val, ...)

add_option_group(*args, **kwargs)
add_options(option_list)
add_transformation(*args, **kwargs)
check_values(values, args)

check_values(values : Values, args : [string]) -> (values : Values, args : [string])

Check that the supplied option values and leftover arguments are valid. Returns the option values and leftover arguments (possibly adjusted, possibly completely new – whatever you like). Default implementation just returns the passed-in values; subclasses may override as desired.

destroy()

Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable.

disable_interspersed_args()

Set parsing to stop on the first non-option. Use this if you have a command processor which runs another command that has options of its own and you want to make sure these options don’t get confused.

enable_interspersed_args()

Set parsing to not stop on the first non-option, allowing interspersing switches with command arguments. This is the default behavior. See also disable_interspersed_args() and the class documentation description of the attribute allow_interspersed_args.

error(msg)

error(msg : string)

Print a usage message incorporating ‘msg’ to stderr and exit. If you override this in a subclass, it should not return – it should either exit or raise an exception.

exit(status=0, msg=None)
expand_prog_name(s)
format_description(formatter)
format_epilog(formatter)
format_help(formatter=None)
format_option_help(formatter=None)
get_default_values()
get_description()
get_option(opt_str)
get_option_group(opt_str)
get_prog_name()
get_usage()
get_version()
grok_args()
has_option(opt_str)
parse_args(args=None, values=None)
parse_args(args : [string] = sys.argv[1:],
values : Values = None)

-> (values : Values, args : [string])

Parse the command-line options found in ‘args’ (default: sys.argv[1:]). Any errors result in a call to ‘error()’, which by default prints the usage message to stderr and calls sys.exit() with an error message. On success returns a pair (values, args) where ‘values’ is an Values instance (with all your option values) and ‘args’ is the list of arguments left over after parsing options.

print_help(file=None)

print_help(file : file = stdout)

Print an extended help message, listing all options and any help text provided with them, to ‘file’ (default stdout).

print_usage(file=None)

print_usage(file : file = stdout)

Print the usage message for the current program (self.usage) to ‘file’ (default stdout). Any occurence of the string “%prog” in self.usage is replaced with the name of the current program (basename of sys.argv[0]). Does nothing if self.usage is empty or not defined.

print_version(file=None)

print_version(file : file = stdout)

Print the version message for this program (self.version) to ‘file’ (default stdout). As with print_usage(), any occurence of “%prog” in self.version is replaced by the current program’s name. Does nothing if self.version is empty or undefined.

process_names_file(options)
process_slice(options)
remove_option(opt_str)
set_conflict_handler(handler)
set_default(dest, value)
set_defaults(**kwargs)
set_description(description)
set_process_default_values(process)
set_usage(usage)
class tl.rename.cli.Transformation(parser, *args, **kwargs)

Bases: optparse.Option

An option that defines a file name transformation.

Stores whether transformations have been specified on the command line.

check_value(opt, value)
convert_value(opt, value)
get_opt_string()
process(opt, value, values, parser)
take_action(*args, **kwargs)
takes_value()

Exceptions

class tl.rename.cli.CommandLineError

Bases: exceptions.Exception

Signals that the user wants rename to do something impossible.

args
message

exception message

Table Of Contents

Previous topic

tl.rename.interactive

Next topic

tl.rename.core

This Page