Пример #1
0
if all_at_once:
    proto_folders = [proto_files]

for proto_files in proto_folders:
    for proto_file in proto_files:
        commands.append(
            """"{0}" --proto_path="{1}" --{2}_out={3}:"{4}" {5} {6}""".format(
                args.protoc_path, out_path, args.language, options, out_path,
                arguments, '"' + proto_file + '"'))

for command in commands:
    call(command, shell=True)

if args.language == 'python':
    compile_helper.finish_compile(out_path, args.language)

elif args.language == 'ruby':
    for path in protos:
        with open(os.path.join(out_path, *path.split('/')) + '.rb',
                  'w') as file:
            for name in protos[path]:
                file.write('require "' + path + '/' + name + '"\n')

# Remove all .proto files
if not args.keep_proto_files:
    for folder_path, _, file_names in os.walk(out_path):
        for file_name in file_names:
            if file_name.endswith(".proto"):
                os.unlink(os.path.join(folder_path, file_name))
Пример #2
0
            call(command, shell=True)

        elif os.path.isdir(item_path):
            compile_directories(item_path)

walk_directory(proto_path)

# Compile =)
if desc_file:
    root_package_file_path = os.path.join(tmp_path, "POGOProtos.proto")
    with open(root_package_file_path, 'a') as root_package_file:
        walk_files(root_package_file, proto_path, "POGOProtos", created_packages)

    command = """{0} --include_imports --proto_path="{1}" --descriptor_set_out="{2}" "{3}\"""".format(
        protoc_path,
        tmp_path,
        os.path.abspath(out_path + "/POGOProtos.desc"),
        os.path.join(tmp_path, "POGOProtos.proto")
    )

    call(command, shell=True)
else:
    if lang == "go":
        compile_go_package(tmp_path)
    else:
        compile_directories(tmp_path)

    compile_helper.finish_compile(out_path, lang)

print("Done!")