Exemplo n.º 1
0
def build_all(file_data, output=None):
    input = clean_json(json.loads(file_data.decode('ascii', 'ignore')))
    validation_warnings, validation_errors = validate_spec(input)
    build_data = ""
    build_errors = []
    if not validation_errors:
        new_package = compile_spec(input)
        files = {}
        files.update(build_python(to_dict(new_package)))
        files.update(build_java(to_dict(new_package)))
        files.update(build_racket(to_dict(new_package)))
        if output is None:
            build_data, build_errors = build_zip(files)
        else:
            build_data, build_errors = build_dir(files, output)
    return validation_warnings, validation_errors, build_data, build_errors
Exemplo n.º 2
0
def build_all(file_data, output=None):
    input = clean_json(json.loads(file_data.decode('ascii', 'ignore')))
    validation_warnings, validation_errors = validate_spec(input)
    build_data = ""
    build_errors = []
    if not validation_errors:
        new_package = compile_spec(input)
        files = {}
        files.update(build_python(to_dict(new_package)))
        files.update(build_java(to_dict(new_package)))
        files.update(build_racket(to_dict(new_package)))
        if output is None:
            build_data, build_errors = build_zip(files)
        else:
            build_data, build_errors = build_dir(files, output)
    return validation_warnings, validation_errors, build_data, build_errors
Exemplo n.º 3
0
    if not fast:
        new_file, database_file = build_database(model)
        sql_file = name+".sql"
        build_locals(model, database_file, sql_file)
        database_file.close()
        moves = {new_file: new_folder, sql_file: new_folder}
        for appendix in model['metadata']['appendix']:
            moves[appendix['file']] = new_folder
    else:
        moves = {}
    
    return files, moves
    
if __name__ == "__main__":
    import json
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1],'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print("Warning!", warning)
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_sql(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print("Error!", error)
Exemplo n.º 4
0

def build_java(model):
    files = {
        'java/libs/StickyWeb-doc-2.5.jar':
        copy_file(templates + 'libs/StickyWeb-doc-2.5.jar')
    }
    files.update(build_metafiles(model))
    files.update(build_main(model))
    files.update(build_classes(model))
    return files


if __name__ == "__main__":
    import json
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1], 'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print "Warning!", warning
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_java(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print "Error!", error
Exemplo n.º 5
0
 with open(a_spec, 'r') as specification_file:
     specification = yaml.load(specification_file)
     # pprint(specification)
     compiled, warnings, errors = Compiler(a_spec, specification).run()
     # print("*"*10)
     if warnings:
         print("\tWarnings!")
         for warning in warnings:
             print("\t\t", warning)
     if errors:
         print("\tErrors!")
         for error in errors:
             print("\t\t", error)
     # print("*"*10)
     language_target = args.language.lower()
     compiled_dict = to_dict(compiled)
     
     #
     # Target Builder Dispatcher
     #
     if language_target == "python":
         files, moves = build_python(compiled_dict, args.fast)
     elif language_target == "csv":
         files, moves = build_csv(compiled_dict)
     elif language_target == "json":
         files, moves = build_json(compiled_dict)
     elif language_target == "racket":
         files, moves = build_racket(compiled_dict, args.fast)
     elif language_target == "java":
         files, moves = build_java(compiled_dict, args.fast)
     elif language_target == "sql":
Exemplo n.º 6
0
    if not fast:
        new_file, database_file = build_database(model)
        build_locals(model, database_file)
        
        database_file.close()
        moves = {new_file: new_folder}
        for appendix in model['metadata']['appendix']:
            moves[appendix['file']] = new_folder
    else:
        moves = {}
    
    return files, moves
    
if __name__ == "__main__":
    import json
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1],'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print "Warning!", warning
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_python(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print "Error!", error
Exemplo n.º 7
0
        with open(splash_file, 'rb') as splash_data:
            files[new_folder+name+"_splash.png"] = splash_data.read()
    else:
        model["metadata"]["splash"] = False
    
    if not fast:
        moves = {f: new_folder for f in build_locals(model, new_folder)}
    else:
        moves = {}
        
    files.update(build_metafiles(model))
    
    return files, moves
    
if __name__ == "__main__":
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1],'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print("Warning!", warning)
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_visualizer(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print("Error!", error)
Exemplo n.º 8
0
 if args.all:
     args.spec = glob.glob(args.spec+'*.corgis')
 else:
     args.spec = [args.spec]
 
 if len(args.spec) > 1 and progressbar is not None:
     pbar = progressbar.ProgressBar(widgets=[progressbar.ReverseBar('<'),
        ' ', progressbar.Percentage(), ' ', progressbar.ETA()]).start()
 else:
     pbar = list
 for a_spec in pbar(args.spec):
     print a_spec
     with open(a_spec, 'r') as specification_file:
         specification = yaml.load(specification_file)
         #pprint(specification)
         compiled, warnings, errors = Compiler(a_spec, specification).run()
         #print("*"*10)
         if warnings: print "\tWarnings!"
         for warning in warnings:
             print "\t\t", warning
         if errors: print "\tErrors!"
         for error in errors:
             print "\t\t", error
         #print("*"*10)
         pprint(to_dict(compiled))
         if args.language.lower() == "python":
             files, moves = build_python(to_dict(compiled), args.fast)
             build_data, build_errors = build_dir(files, moves, args.target)
         elif args.language.lower() == "csv":
             files, moves = build_csv(to_dict(compiled))
             build_data, build_errors = build_dir(files, moves, args.target)
Exemplo n.º 9
0
    if not fast:
        new_file, database_file = build_database(model)
        build_locals(model, database_file)
        
        database_file.close()
        moves = {new_file: new_folder}
        for appendix in model['metadata']['appendix']:
            moves[appendix['file']] = new_folder
    else:
        moves = {}
    
    return files, moves
    
if __name__ == "__main__":
    import json
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1],'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print("Warning!", warning)
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_racket(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print("Error!", error)
Exemplo n.º 10
0
    full_key_descriptions = [i[4] for i in results]

    tifa_definitions = []
    for interface, s in zip(model['interfaces'], results):
        tifa_definitions.append(
            (interface['name'], TifaDefinition(s[5]).result))

    files.update(
        build_metafiles(model, key_names, indexes, full_key_descriptions,
                        tifa_definitions))

    return files, moves


if __name__ == "__main__":
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1], 'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print("Warning!", warning)
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_blockpy(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print("Error!", error)
Exemplo n.º 11
0
    return files
                
def copy_file(filename):
    with open(filename, 'rb') as input:
        return input.read()

def build_java(model):
    files = {'java/libs/StickyWeb-doc-2.5.jar' : copy_file(templates+'libs/StickyWeb-doc-2.5.jar')}
    files.update(build_metafiles(model))
    files.update(build_main(model))
    files.update(build_classes(model))
    return files
    
if __name__ == "__main__":
    import json
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1],'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print "Warning!", warning
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_java(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print "Error!", error
Exemplo n.º 12
0
        new_file, database_file = build_database(model)
        build_locals(model, database_file)

        database_file.close()
        moves = {new_file: new_folder}
        for appendix in model['metadata']['appendix']:
            moves[appendix['file']] = new_folder
    else:
        moves = {}

    return files, moves


if __name__ == "__main__":
    import json
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1], 'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print("Warning!", warning)
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_python(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print("Error!", error)
Exemplo n.º 13
0
    if not fast:
        new_file, database_file = build_database(model)
        sql_file = name+".sql"
        build_locals(model, database_file, sql_file)
        database_file.close()
        moves = {new_file: new_folder, sql_file: new_folder}
        for appendix in model['metadata']['appendix']:
            moves[appendix['file']] = new_folder
    else:
        moves = {}
    
    return files, moves
    
if __name__ == "__main__":
    import json
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1],'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print("Warning!", warning)
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_sql(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print("Error!", error)
Exemplo n.º 14
0
            files[new_folder+name+'.png'] = icon_data.read()
    else:
        model["metadata"]["icon"] = False
    
    results = list(build_locals(model, new_folder))
    moves = {f: new_folder for f in first_items(results)}
    key_names = [k for s in results for k in s[1]]
    indexes = {k:v for s in results for k, v in s[2].items()}
    full_key_descriptions = [i[3] for i in results]
        
    files.update(build_metafiles(model, key_names, indexes, full_key_descriptions))
    
    return files, moves
    
if __name__ == "__main__":
    from auxiliary import clean_json
    input = clean_json(json.load(open(sys.argv[1],'r')))
    from validate import validate_spec
    warnings, errors = validate_spec(input)
    for warning in warnings:
        print("Warning!", warning)
    if not errors:
        from compile import compile_spec
        new_package = compile_spec(input)
        files = build_blockpy(to_dict(new_package))
        from build import build_dir
        build_dir(files, sys.argv[2])
    else:
        for error in errors:
            print("Error!", error)