import os.path
from shutil import copyfile
try:
    from jinja2 import Template
except:
    print "Could not import Jinja2, run 'easy_install Jinja2'"
    exit()

output_dir = os.path.join('./', 'chrome_webstore')

if not os.path.exists(output_dir):
    os.makedirs(output_dir)

def add_background_script():
    copyfile('chrome_webstore_background.js', os.path.join(output_dir, 'background.js'))

def add_manifest():
    copyfile('chrome_webstore_manifest.json', os.path.join(output_dir, 'manifest.json'))

def render_main_template():
    f = open('./html/index.html')
    template = Template(f.read().decode('utf-8'))
    f.close()

    html = template.render(og_tag='', url='', ON_PRODUCTION=True, ON_DEV=False, USE_PRODUCTION_JAVASCRIPT=True)
    f = open(os.path.join(output_dir, 'index.html'), 'w')
    f.write(html.encode('utf-8'))
    f.close()

    print "Template rendered"

add_manifest()
add_background_script()
render_main_template()

@@ -36,16 +36,70 @@
 opyfile%0A
+from shutil import copytree%0Afrom shutil import rmtree%0A
 try:%0A   
@@ -265,20 +265,16 @@
 e')%0A%0Aif 
-not 
 os.path.
@@ -297,16 +297,36 @@
 r):%0A    
+rmtree(output_dir)%0A%0A
 os.maked
@@ -457,24 +457,228 @@
 ound.js'))%0A%0A
+def copy_static_dirs():%0A    copytree('images', os.path.join(output_dir, 'images'))%0A    copytree('styles', os.path.join(output_dir, 'styles'))%0A    copytree('scripts', os.path.join(output_dir, 'scripts'))%0A%0A
 def add_mani
@@ -1191,16 +1191,16 @@
 cript()%0A
-
 render_m
@@ -1210,12 +1210,31 @@
 _template()%0A
+copy_static_dirs()%0A

Copy static dirs as well