'''
Utility module to help with setting up the initial contents of the
JOY_HOME directory.

These contents are kept in this Python module as a base64-encoded zip
file, so you can just do, e.g.:

    import init_joy_home
    init_joy_home.initialize(JOY_HOME)

'''
import base64, os, StringIO, zipfile


def initialize(joy_home):
    Z.extractall(joy_home)


def create_data(from_dir='./default_joy_home'):
    f = StringIO.StringIO()
    z = zipfile.ZipFile(f, mode='w')
    for fn in os.listdir(from_dir):
        from_fn = os.path.join(from_dir, fn)
        z.write(from_fn, fn)
    z.close()
    return base64.encodestring(f.getvalue())


Z = zipfile.ZipFile(StringIO.StringIO(base64.decodestring('''\
[encoded data, 5313 characters]
AAAAAAAAAAAAtIH2BgAAZGVmaW5pdGlvbnMudHh0UEsFBgAAAAAFAAUAHgEAAF0OAAAAAA==''')))


if __name__ == '__main__':
    print create_data()
