craftr.ext.archive

Classes

class craftr.ext.archive.Archive(name=None, base_dir=None, prefix=None, format='zip')[source]

Helper class to build and a list of files for an archive and then create that archive from that list. If no name is specified, it is derived from the prefix. The format must be 'zip' for now.

add(name, rel_dir=None, arc_name=None, parts=None)[source]

Add a file, directory or Target to the archive file list. If parts is specified, it must be a number which specifies how many parts of the arc name are kept from the right.

Note

name can be a filename, the path to a directory, a glob pattern or list. Note that a directory will be globbed for its contents and will then be added recursively. A glob pattern that yields a directory path will add that directory.

exclude(filter)[source]

Remove all files in the Archive’s file list that match the specified filter. The filter can be a string, in which case it is applied with fnmatch() or a function which accepts a single argument (the filename).

rename(old_arcname, new_arcname)[source]

Rename the old_arcname to new_arcname. This will take folders into account.

save()[source]

Save the archive.