Reference

Shell-like commands for scripting development

scripting.commands.archive(src, dst, format='tar')[source]

Create an archive dst from the directory src. The format can be specified with the format parameter that can be:

  • tar
  • gzip
  • bz2
  • zip
scripting.commands.basename(src)[source]

Unix basename

scripting.commands.cp(*args, **kw)[source]

Copy files and directories

Parameters:src – can be a string or an iterable and is the file/s to copy

;param dst: the destination file or directory

scripting.commands.find(glob, startdir='.')[source]

Return a list of files that matches glob

Parameters:
  • glob – is the pattern to search for like *.py or *.py?
  • startdir – the path from where to search
scripting.commands.mkdir(*args, **kw)[source]

Make a directory

Parameters:parent – if True, create all the directory structure
scripting.commands.rm(*args, **kw)[source]

Remove a file or a directory

Parameters:src – a string or an iterable, representing the file/s to remove
scripting.commands.sh(cmdl, args=[])[source]

Simple function to run shell_commands it takes a shell command line cmdln, optionally further arguments args.

Returns a tuple, (exitcode, output, error)

scripting.commands.take_str_or_list(f)[source]

Allow the function decorated to take as the first argument a string or an iterable.

If the first arg is a string, call f with the string as the first argument, if the first argument is an iterable, call f on each item of the iterable and return a list of the results.

scripting.commands.touch(*args, **kw)[source]

Create src file if it doesn’t exists or update his modification time according to times.

scripting.commands.unpack(src, dst, format=None)[source]

Unpack the archive src in the destination directory dst. The format can be tar, gzip, bz2, zip or None to auto-select the format based on the extension.

Module to control the interaction with the shell Bash

scripting.bash.source(fname)[source]

Emulate the source command in bash, reading the environment from a script.