Exemple #1
0
def walk_directory(path):
    for dir_name in os.listdir(path):
        dir_name_path = os.path.join(path, dir_name)
        if os.path.isdir(dir_name_path):
            package = get_package(dir_name_path)
            if package is not None:
                if lang == "go":
                    file_name = go_helper.convert_to_go_package(package)
                    package_mappings.append(
                        [file_name, (file_name + ".proto")])
                else:
                    file_name = package
                    package_mappings.append(
                        [file_name, (file_name + ".proto")])

                package_file_path = os.path.join(tmp_path,
                                                 file_name + ".proto")

                if lang == "go":
                    package_directory = os.path.dirname(package_file_path)
                    compile_helper.mkdir_p(package_directory)

                with open(package_file_path, 'a') as package_file:
                    walk_files(package_file, dir_name_path, package)
                    created_packages.append(package)

            walk_directory(dir_name_path)
def walk_directory(path):
    for dir_name in os.listdir(path):
        dir_name_path = os.path.join(path, dir_name)
        if os.path.isdir(dir_name_path):
            package = get_package(dir_name_path)
            if package is not None:
                if lang == "go":
                    file_name = go_helper.convert_to_go_package(package)
                    package_mappings.append([file_name, (file_name + ".proto")])
                else:
                    file_name = package
                    package_mappings.append([file_name, (file_name + ".proto")])

                package_file_path = os.path.join(tmp_path, file_name + ".proto")

                if lang == "go":
                    package_directory = os.path.dirname(package_file_path)
                    compile_helper.mkdir_p(package_directory)

                with open(package_file_path, 'a') as package_file:
                    walk_files(package_file, dir_name_path, package)
                    created_packages.append(package)

            walk_directory(dir_name_path)