includer.py: process embedded includes
|
Download
To obtain my PGP/GnuPG key, see these instructions. Documentation
Back to software page. |
NOTE: This module has become part of The Grizzled Utility API. (See the grizzled.file.includer module.) This stand-alone version is no longer maintained. IntroductionThe includer module contains a class that can be used to process includes within a text file, returning a file-like object.Include SyntaxThe include syntax is defined by a regular expression; any line that matches the regular expression is treated as an include directive. The default regular expression matches include directives like this:
%include "/absolute/path/to/file"
%include "../relative/path/to/file"
%include "local_reference"
%include "http://localhost/path/to/my.config"
Relative and local file references are relative to the including file or URL. That, if an Includer is processing file "/home/bmc/foo.txt" and encounters an attempt to include file "bar.txt", it will assume "bar.txt" is to be found in "/home/bmc". Similarly, if an Includer is processing URL "http://localhost/bmc/foo.txt" and encounters an attempt to include file "bar.txt", it will assume "bar.txt" is to be found at "http://localhost/bmc/bar.txt". Nested includes are permitted; that is, an included file may, itself, include other files. The maximum recursion level is configurable and defaults to 100. The include syntax can be changed by passing a different regular expression to the Includer class constructor. The module also provides a preprocess() convenience function that can be used to preprocess a file; it returns the path to the resulting preprocessed file. See the full documentation for details. InstallationThe usual:
easy_install includer AuthorBrian M. Clapper, <bmc @ clapper . org> Copyright© 2008 Brian M. Clapper LicenseBSD-style license. See accompanying LICENSE file. $Id: index.html,v 1.7 2005/05/20 14:37:58 bmc Exp $
|