The packmail Module

(Obsolete) The packmail module contains tools to create Unix shell archives. If you have the right tools installed (if you have a Unix box, they are installed), you can unpack such an archive simply by executing it. Example 6-10 shows how to pack a single file using packmail, while Example 6-11 shows how the module can pack an entire directory tree.

Example 6-10. Using the packmail Module to Pack a Single File

File: packmail-example-1.py import packmail import sys packmail.pack(sys.stdout, "samples/sample.txt", "sample.txt") echo sample.txt sed "s/^X//" >sample.txt <<"!" XWe will perhaps eventually be writing only small Xmodules, which are identified by name as they are Xused to build larger ones, so that devices like Xindentation, rather than delimiters, might become Xfeasible for expressing local structure in the Xsource language. X -- Donald E. Knuth, December 1974 !

Example 6-11. Using the packmail Module to Pack an Entire Directory Tree

File: packmail-example-2.py import packmail import sys packmail.packtree(sys.stdout, "samples")

Note that this module cannot handle binary files, such as sound snippets and images.

Категории