import json
import sys
import os

f = open(sys.argv[1])
out = sys.argv[2]
data = json.load(f)

for key in data["files"]:
	val = data["files"][key]
        try:
            os.makedirs(out + "/" + os.path.dirname(key))
        except:
            print "ignoring error"

	if type(val) == str or type(val) == unicode:
		print "Symlinking " + out + "/" + key
		os.symlink(val, out + "/" + key)

        if type(val) == dict:
                print "Creating file " + out + "/" + key
                o = open(out + "/" + key, "w")
                o.write(val["content"])


import json
import sys
import os

f = open(sys.argv[1])
out = sys.argv[2]
data = json.load(f)

for key in data["files"]:
    val = data["files"][key]
    try:
        os.makedirs(out + "/" + os.path.dirname(key))
    except:
        print "ignoring error"

    if type(val) == str or type(val) == unicode:
        print "Symlinking " + out + "/" + key
        os.symlink(val, out + "/" + key)

    if type(val) == dict:
        print "Creating file " + out + "/" + key
        with open(out + "/" + key, "w") as f:
            f.write(val["content"].encode('UTF-8'))


Fix errors when contents of a file contains UTF-8 chars.
Fix errors when contents of a file contains UTF-8 chars.

- Convert tabs to spaces.
- Use a more pythonic way to open (and write into) the file.
- Add UTF-8 encoding before writing the contents of the file.
