import json
import sys
from optparse import OptionParser

def parse_args():
    parser = OptionParser()
    parser.add_option("-m", "--module", dest="module_path",
                      help="Specify the module path which you want to export into json")
    (options, args) = parser.parse_args()
    return options

def export(module_path):
    module_path = module_path.strip(".py")
    module_path = module_path.replace(r'/', '.')
    local_settings = __import__(module_path)
    print "'%s'" % json.dumps(local_settings.SETTINGS)

def main():
    options = parse_args()
    if not options.module_path:
        raise SystemExit, "Please specify module path to import"

    export(options.module_path)

if __name__ == "__main__":
    main()
