[Chicago] paster quickstart?

Lukasz Szybalski szybalski at gmail.com
Sat Jun 7 22:50:26 CEST 2008


On Sat, Jun 7, 2008 at 12:41 PM, Kumar McMillan
<kumar.mcmillan at gmail.com> wrote:
> On Fri, Jun 6, 2008 at 11:15 PM, Lukasz Szybalski <szybalski at gmail.com> wrote:
>> Hello,
>> I read that I could use paster to create a skeleton for a project.?!@?
>> That is great, but my next step is to tell my program to ask user for
>> input filenames and based on that it will need to create 5 .py files
>> for each filename.
>> I need to substitute the names of few fields in the .py files and add
>> some things depending on extension.
>>
>> Normally I would do it with some python template, but I heard I could
>> do that with paster maybe? Is that true, is there a different tool I
>> should be using?
>>
>> Where do I start?
>
> You can start here : http://pythonpaste.org/script/developer.html
>
> Then you may want to look at the CreateDistroCmd:
> http://svn.pythonpaste.org/Paste/Script/trunk/paste/script/create_distro.py
>
> You will probably need one set of templates per extension, to dictate
> each variation of a file layout.  Within each template dir, Paste
> allows you to use variables in file names by putting plus signs
> between the variable name, like:
>
> templates/
>    +input_file+.py_tmpl
>
> that will use the var "input_file" to name the final .py file.  And
> since it ends in py_tmpl, Paste will interpolate variables within the
> file as well (i.e. {{your_var}} ).  In your command() method of your
> Paste Command class you might prompt the user like this:
>
> vars = {}
> if self.interactive:
>    vars['input_file'] = self.challenge('Enter input file')
> else:
>    # check the command line... then
>    raise BadCommand('You must provide an INPUT_FILE when non-interactive')
> vars.update(self.parse_vars(self.args[1:]))
>
> then I suppose you'd have to decide what template package to use based
> on file extension and you'd render each in a loop per input file.  in
> that loop, rendering looks something like:
>
> template.check_vars(vars, self)
> self.create_template(template, output_dir, vars)

Thanks,
That should get me started...
I also found these 2 pages:
http://www.percious.com/blog/?tag=python-setuptools-paster-paste-omnigraffle-agile
http://wiki.pylonshq.com/display/pylonscookbook/Creating%20Templates%20For%20The%20paster%20create%20Command


>
> btw, the paste list would probably be a great place to continue
> discussing paste ;)
> http://pythonpaste.org/community/mailing-list.html
will do.

Lucas


-- 
Where was my car manufactured?
http://cars.lucasmanual.com/vin
TurboGears Manual-Howto
http://lucasmanual.com/pdf/TurboGears-Manual-Howto.pdf


More information about the Chicago mailing list