{
    "mode": "pydoc",
    "parameter": "pipes",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/pipes/json",
    "generated": "2026-06-02T15:53:07Z",
    "sections": {
        "NAME": {
            "content": "pipes - Conversion pipeline templates.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/pipes.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The problem:\n------------\n\nSuppose you have some data that you want to convert to another format,\nsuch as from GIF image format to PPM image format.  Maybe the\nconversion involves several steps (e.g. piping it through compress or\nuuencode).  Some of the conversion steps may require that their input\nis a disk file, others may be able to read standard input; similar for\ntheir output.  The input to the entire conversion may also be read\nfrom a disk file or from an open file, and similar for its output.\n\nThe module lets you construct a pipeline template by sticking one or\nmore conversion steps together.  It will take care of creating and\nremoving temporary files if they are necessary to hold intermediate\ndata.  You can then use the template to do conversions from many\ndifferent sources to many different destinations.  The temporary\nfile names used are different each time the template is used.\n\nThe templates are objects so you can create templates for many\ndifferent conversion steps and store them in a dictionary, for\ninstance.\n\n\nDirections:\n-----------\n\nTo create a template:\nt = Template()\n\nTo add a conversion step to a template:\nt.append(command, kind)\nwhere kind is a string of two characters: the first is '-' if the\ncommand reads its standard input or 'f' if it requires a file; the\nsecond likewise for the output. The command must be valid /bin/sh\nsyntax.  If input or output files are required, they are passed as\n$IN and $OUT; otherwise, it must be  possible to use the command in\na pipeline.\n\nTo add a conversion step at the beginning:\nt.prepend(command, kind)\n\nTo convert a file to another file using a template:\nsts = t.copy(infile, outfile)\nIf infile or outfile are the empty string, standard input is read or\nstandard output is written, respectively.  The return value is the\nexit status of the conversion pipeline.\n\nTo open a file for reading or writing through a conversion pipeline:\nfp = t.open(file, mode)\nwhere mode is 'r' to read the file, or 'w' to write it -- just like\nfor the built-in function open() or for os.popen().\n\nTo create a new template object initialized to a given one:\nt2 = t.clone()\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.object\nTemplate\n",
            "subsections": [
                {
                    "name": "class Template",
                    "content": "|  Class representing a pipeline template.\n|\n|  Methods defined here:\n|\n|  init(self)\n|      Template() returns a fresh pipeline template.\n|\n|  repr(self)\n|      t.repr() implements repr(t).\n|\n|  append(self, cmd, kind)\n|      t.append(cmd, kind) adds a new step at the end.\n|\n|  clone(self)\n|      t.clone() returns a new pipeline template with identical\n|      initial state as the current one.\n|\n|  copy(self, infile, outfile)\n|\n|  debug(self, flag)\n|      t.debug(flag) turns debugging on or off.\n|\n|  makepipeline(self, infile, outfile)\n|\n|  open(self, file, rw)\n|      t.open(file, rw) returns a pipe or file object open for\n|      reading or writing; the file is the other end of the pipeline.\n|\n|  openr(self, file)\n|      t.openr(file) and t.openw(file) implement\n|      t.open(file, 'r') and t.open(file, 'w') respectively.\n|\n|  openw(self, file)\n|\n|  prepend(self, cmd, kind)\n|      t.prepend(cmd, kind) adds a new step at the front.\n|\n|  reset(self)\n|      t.reset() restores a pipeline template to its initial state.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                }
            ]
        },
        "DATA": {
            "content": "all = ['Template']\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/pipes.py\n\n",
            "subsections": []
        }
    },
    "summary": "pipes - Conversion pipeline templates.",
    "flags": [],
    "examples": [],
    "see_also": []
}