getpelican/pelican — pull request #1017 by videan42 (2013-08-07 00:45:37+00:00)
Title: Add a programmatic interface to the quickstart template generator

TLDR: Pelican quickstart gives me a really nice way to setup my blog, but it's really hard to use in a deployment script. Here's a patch that makes it easier.

I was working on writing a script to deploy my blog from scratch (provision servers, install software, etc), and I ran into a speedbump. Maybe I'm dumb, but I can't figure out a way to run quickstart from python if I already have a config ready to go. It's kind of hard to deal with quickstart from python because of all the calls to ``input()``.

```python
>>> import subprocess
>>> proc = subprocess.Popen('pelican-quickstart', stdin=subprocess.PIPE)
Welcome to pelican-quickstart v3.2.0.

This script will help you create a new Pelican-based website.

Please answer the following questions so this script can generate the files
needed by Pelican.
# Ummm?
>>> proc.communicate('stuff')
# ... something something decode error
```

I looked at my options, and I can either fake the inputs with ``pexpect`` (which is a pain to maintain), or I could fake how the templates are generated (which is also a pain to maintain), or I could modify quickstart. I looked at the generation code, and it's really easy to split the input dialogs from the actual generation of code.

The attached pull request implements that split. Tested against 2.7 and 3.3.