
from subprocess import check_call
import urllib
import json
import os
import os.path

def install():
    with open('.bowerrc') as f:
        bowerrc = json.load(f)
    with open('bower.json') as f:
        bower_json = json.load(f)

    registry = 'https://bower.herokuapp.com'
    topdir = os.path.abspath(os.curdir)

    for pkg in bower_json['dependencies'].keys():
        req = urllib.urlopen('%s/packages/%s' % (registry, pkg))
        info = json.load(req)
        os.chdir(bowerrc['directory'])
        check_call(['git', 'clone', info['url']])
        os.chdir(pkg)
        install()
        os.chdir(topdir)

@@ -458,16 +458,114 @@
 ad(req)%0A
+        if not os.path.isdir(bowerrc%5B'directory'%5D):%0A            os.makedirs(bowerrc%5B'directory'%5D)%0A
         

Make the destination directory if it does not exist