Logo Search packages:      
Sourcecode: jaxml version File versions  Download package

def jaxml::XML_document::__subst_lines (   self,
  lines,
  vars 
) [private]
Substitues var names with their values.

   parts of this function come from the Whiz package
   THANKS TO Neale Pickett ! Here follows the original license terms for Whiz:
        ## Author: Neale Pickett <neale@lanl.gov>
        ## Time-stamp: <99/02/11 10:45:42 neale>

        ## This software and ancillary information (herein called "SOFTWARE")
        ## called html.py made avaiable under the terms described here.  The
        ## SOFTWARE has been approved for release with associated LA-CC Number
        ## 89-47.

        ## Unless otherwise indicated, this SOFTWARE has been authored by an
        ## employee or employees of the University of California, operator of
        ## the Los Alamos National Laboratory under contract No. W-7405-ENG-36
        ## with the U.S. Department of Energy.  The U.S. Government has rights
        ## to use, reproduce, and distribute this SOFTWARE.  The public may
        ## copy, distribute, prepare derivative works and publicly display this
        ## SOFTWARE without charge, provided that this Notice and any statement
        ## of authorship are reproduced on all copies.  Neither the Government
        ## nor the University makes any warranty, express or implied, or assumes
        ## any liability or responsibility for the use of this SOFTWARE.

        ## If SOFTWARE is modified to produce derivative works, such modified
        ## SOFTWARE should be clearly marked, so as not to confuse it with the
        ## version available from LANL.

Definition at line 756 of file jaxml.py.

                                              :
                """Substitues var names with their values.

                   parts of this function come from the Whiz package
                   THANKS TO Neale Pickett ! Here follows the original license terms for Whiz:
                        ## Author: Neale Pickett <neale@lanl.gov>
                        ## Time-stamp: <99/02/11 10:45:42 neale>

                        ## This software and ancillary information (herein called "SOFTWARE")
                        ## called html.py made avaiable under the terms described here.  The
                        ## SOFTWARE has been approved for release with associated LA-CC Number
                        ## 89-47.

                        ## Unless otherwise indicated, this SOFTWARE has been authored by an
                        ## employee or employees of the University of California, operator of
                        ## the Los Alamos National Laboratory under contract No. W-7405-ENG-36
                        ## with the U.S. Department of Energy.  The U.S. Government has rights
                        ## to use, reproduce, and distribute this SOFTWARE.  The public may
                        ## copy, distribute, prepare derivative works and publicly display this
                        ## SOFTWARE without charge, provided that this Notice and any statement
                        ## of authorship are reproduced on all copies.  Neither the Government
                        ## nor the University makes any warranty, express or implied, or assumes
                        ## any liability or responsibility for the use of this SOFTWARE.

                        ## If SOFTWARE is modified to produce derivative works, such modified
                        ## SOFTWARE should be clearly marked, so as not to confuse it with the
                        ## version available from LANL.
                """
                import regex

                container = regex.compile('\(<!-- \)?##\([-_A-Za-z0-9]+\)##\( -->\)?')
                for line in lines:
                        while container.search(line) != -1:
                                try:
                                        replacement = str(vars[container.group(2)])
                                except KeyError:
                                        replacement = str('<!-- Unmatched variable: ' + container.group(2) + ' -->')

                                pre = line[:container.regs[0][0]]
                                post = line[container.regs[0][1]:]
                                if string.strip(pre) == '':
                                        # pre is just whitespace, so pad our replacement's lines with that space
                                        lines = string.split(replacement, '\n')
                                        new = [lines[0]]
                                        for l in lines[1:]:
                                                new.append(pre + l)
                                        replacement = string.join(new, '\n')
                                line = "%s%s%s" % (pre, replacement, post)
                        self._text(line)


Generated by  Doxygen 1.6.0   Back to index