Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 68 lines (54 sloc) 1.6 KB
#!/usr/bin/env python
import urllib
import urllib2
import shutil
import sys
import zipfile
import os
# Welcome the user
print "I'm going to ask you for some information about your theme.\n"
print "You have to give your theme a name but you can leave the others blank if you want.\n"
print "Let's get started.\n"
# Get your customizations
name = raw_input('Name? ')
# You need to provide at least a name
if not name:
print 'You need a name for your theme'
# ... and it needs to be unique
if os.path.exists(name) or os.path.exists(name + '.zip'):
print "You should pick a name that isn't already used for a file or directory"
slug = raw_input('Slug? ')
author = raw_input('Author? ')
author_uri = raw_input('Author URI? ')
description = raw_input('Description? ')
# And a few defaults
generate = 1
generate_submit = 'Generate'
# Parse the inputs
data = {
'underscoresme_name': name,
'underscoresme_slug': slug,
'underscoresme_author': author,
'underscoresme_author_uri': author_uri,
'underscoresme_description': description,
'underscoresme_generate': generate,
'underscoresme_generate_submit': generate_submit
# Setup the request data
body = urllib.urlencode(data)
headers = {'User-Agent': '_sh'}
# Make the request
request = urllib2.Request('', body, headers)
response = urllib2.urlopen(request)
# Save the zip file
target = open(name + '.zip', 'wb')
shutil.copyfileobj(response.fp, target)
# Unzip it
zip = zipfile.ZipFile(name + '.zip')
# Delete the zip file
os.remove(name + '.zip')
Something went wrong with that request. Please try again.