Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
leafstorm
committed
Jul 15, 2010
1 parent
94f30e1
commit 3476e61
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
new-theme.py | ||
============ | ||
This is a simple script that creates a new theme in the given directory. | ||
""" | ||
import os | ||
import os.path | ||
import sys | ||
try: | ||
import simplejson as json | ||
except ImportError: | ||
import json | ||
|
||
|
||
def ident_to_title(ident): | ||
return ident.replace('_', ' ').title() | ||
|
||
|
||
def create_theme(appident, destination): | ||
destination = destination.rstrip(os.path.sep) | ||
identifier = os.path.basename(destination) | ||
data = dict( | ||
application=appident, | ||
identifier=identifier, | ||
name=ident_to_title(identifier), | ||
author='Your Name' | ||
) | ||
os.makedirs(destination) | ||
|
||
info_json = os.path.join(destination, 'info.json') | ||
templates_path = os.path.join(destination, 'templates') | ||
static_path = os.path.join(destination, 'static') | ||
with open(info_json, 'w') as fd: | ||
json.dump(data, fd, indent=4) | ||
os.makedirs(templates_path) | ||
os.makedirs(static_path) | ||
|
||
|
||
if __name__ == '__main__': | ||
args = sys.argv[1:] | ||
scriptname = os.path.basename(sys.argv[0]) | ||
if len(args) < 2: | ||
print "Usage: %s APPIDENT PATH" % scriptname | ||
sys.exit(2) | ||
create_theme(args[0], args[1]) |