#!/usr/bin/env python # -*- coding: utf-8 -*- from os.path import abspath, dirname, join path = dirname(abspath(__file__)) module = join(path, "..") import apitypes from apitypes_debug import enums # generate js enums def main(): print "generating apitypes.js" f = open(join(module, 'web', 'static', 'js', 'utils', 'apitypes.js'), 'wb') f.write("""// Autogenerated, do not edit! define([], function() { \treturn { """) for name in enums: enum = getattr(apitypes, name) values = dict([(attr, getattr(enum, attr)) for attr in dir(enum) if not attr.startswith("_")]) f.write("\t\t%s: %s,\n" % (name, str(values))) f.write("\t};\n});") f.close() if __name__ == "__main__": main()