Loading ...
Sorry, an error occurred while loading the content.

[Cheetahtemplate-discuss] cheetah question,

Expand Messages
  • Vinodh Srinivasasainagendra
    I am using Cheetah to automate the process of creating jobscripts from a template script and its corresponding placeholder values feed from a dictionary. In
    Message 1 of 2 , Jun 9 4:28 PM
    • 0 Attachment
      I am using Cheetah to automate the process of creating jobscripts from a
      template script and its corresponding placeholder values feed from a
      dictionary. In the following piece of code, instead of print template, i
      want to print it to a file.Does the template class take in a fileName as an
      argument to its method and writes the filled template into that file..my
      placeholder values change during every iteration, hence that way i can have
      a new script file generated at the end of every iteration. help ur help on
      this.

      thanks

      ****************************************************************************
      **********************
      import os,sys
      from Cheetah.Template import Template
      nameSpace= {'SInputFile': 'test',
      'SOutputFile': 'results_f ',}

      templateFile = 'jobscript'
      template = Template(file=templateFile,searchList=[nameSpace])
      print template

      ****************************************************************************
      **********************



      -------------------------------------------------------
      This SF.Net email is sponsored by: GNOME Foundation
      Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event.
      GNOME Users and Developers European Conference, 28-30th June in Norway
      http://2004/guadec.org
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • John Landahl
      ... f = open(filename, w ) f.write(str(template)) f.close() ... There s also a Perl-ish extension to the print statement which could replace the f.write()
      Message 2 of 2 , Jun 10 11:16 AM
      • 0 Attachment
        On Wednesday 09 June 2004 04:28 pm, Vinodh Srinivasasainagendra wrote:
        > I am using Cheetah to automate the process of creating jobscripts from a
        > template script and its corresponding placeholder values feed from a
        > dictionary. In the following piece of code, instead of print template, i
        > want to print it to a file.Does the template class take in a fileName as an
        > argument to its method and writes the filled template into that file..

        Just use the usual Python file routines for this:

        > import os,sys
        > from Cheetah.Template import Template
        > nameSpace= {'SInputFile': 'test',
        > 'SOutputFile': 'results_f ',}
        >
        > templateFile = 'jobscript'
        > template = Template(file=templateFile,searchList=[nameSpace])

        f = open(filename, 'w')
        f.write(str(template))
        f.close()

        > print template

        There's also a Perl-ish extension to the print statement which could replace
        the f.write() statement above:

        print >>f, str(template)

        But this use of 'print' is not especially popular with most Python
        programmers...


        -------------------------------------------------------
        This SF.Net email is sponsored by the new InstallShield X.
        From Windows to Linux, servers to mobile, InstallShield X is the
        one installation-authoring solution that does it all. Learn more and
        evaluate today! http://www.installshield.com/Dev2Dev/0504
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      Your message has been successfully submitted and would be delivered to recipients shortly.