def execute(self, src_proto_path, proto_code_dir, excluded_proto_path=[]):
     grpc_proto_dir = os.path.join(proto_code_dir, 'src', 'main', 'proto')
     for proto_path in src_proto_path:
         index = protoc_utils.find_google_dir_index(proto_path)
         for src_proto_file in protoc_utils.find_protos(
                 [proto_path], excluded_proto_path):
             relative_proto_file = src_proto_file[index:]
             dst_proto_file = os.path.join(
                 grpc_proto_dir, relative_proto_file)
             self.exec_command(
                 ['mkdir', '-p', os.path.dirname(dst_proto_file)])
             self.exec_command(['cp', src_proto_file, dst_proto_file])
Beispiel #2
0
 def execute(self, src_proto_path, proto_code_dir, excluded_proto_path=[]):
     grpc_proto_dir = os.path.join(proto_code_dir, 'src', 'main', 'proto')
     for proto_path in src_proto_path:
         index = protoc_utils.find_google_dir_index(proto_path)
         for src_proto_file in protoc_utils.find_protos(
                 [proto_path], excluded_proto_path):
             relative_proto_file = src_proto_file[index:]
             dst_proto_file = os.path.join(
                 grpc_proto_dir, relative_proto_file)
             self.exec_command(
                 ['mkdir', '-p', os.path.dirname(dst_proto_file)])
             self.exec_command(['cp', src_proto_file, dst_proto_file])
 def execute(self, gapic_code_dir, src_proto_path, excluded_proto_path=[]):
     final_output_dir = os.path.join(gapic_code_dir, 'protos')
     for proto_path in src_proto_path:
         index = protoc_utils.find_google_dir_index(proto_path)
         for src_proto_file in protoc_utils.find_protos(
                 [proto_path], excluded_proto_path):
             relative_proto_file = src_proto_file[index:]
             dst_proto_file = os.path.join(
                 final_output_dir, relative_proto_file)
             dst_proto_dir = os.path.dirname(dst_proto_file)
             if not os.path.exists(dst_proto_dir):
                 self.exec_command(['mkdir', '-p', dst_proto_dir])
             self.exec_command(['cp', src_proto_file, dst_proto_file])
Beispiel #4
0
 def execute(self, gapic_code_dir, src_proto_path, excluded_proto_path=[]):
     final_output_dir = os.path.join(gapic_code_dir, 'proto')
     for proto_path in src_proto_path:
         index = protoc_utils.find_google_dir_index(proto_path)
         for src_proto_file in protoc_utils.find_protos(
             [proto_path], excluded_proto_path):
             relative_proto_file = src_proto_file[index:]
             dst_proto_file = os.path.join(final_output_dir,
                                           relative_proto_file)
             dst_proto_dir = os.path.dirname(dst_proto_file)
             if not os.path.exists(dst_proto_dir):
                 self.exec_command(['mkdir', '-p', dst_proto_dir])
             self.exec_command(['cp', src_proto_file, dst_proto_file])
Beispiel #5
0
def test_find_google_dir_index():
    expected = [
        ('google', 0),
        ('google/path', 0),
        ('path/google', 5),
        ('path/google/more', 5),
        ('path\\google\\more', 5),
        ('google/google', 7),
        ('googlea/google/googleb/cgoogle/Google', 8),
    ]
    for path, index in expected:
        assert protoc_utils.find_google_dir_index(path) == index

    failing = [
        '',
        'any/old/path',
        'any\\old\\path',
        'Google',
        'agoogle/googleb',
    ]
    for path in failing:
        with pytest.raises(ValueError):
            protoc_utils.find_google_dir_index(path)
Beispiel #6
0
def test_find_google_dir_index():
    expected = [
        ('google', 0),
        ('google/path', 0),
        ('path/google', 5),
        ('path/google/more', 5),
        ('path\\google\\more', 5),
        ('google/google', 7),
        ('googlea/google/googleb/cgoogle/Google', 8),
    ]
    for path, index in expected:
        assert protoc_utils.find_google_dir_index(path) == index

    failing = [
        '',
        'any/old/path',
        'any\\old\\path',
        'Google',
        'agoogle/googleb',
    ]
    for path in failing:
        with pytest.raises(ValueError):
            protoc_utils.find_google_dir_index(path)
Beispiel #7
0
 def execute(self, gapic_code_dir, src_proto_path, excluded_proto_path=[]):
     final_output_dir = os.path.join(gapic_code_dir, 'protos')
     src_dir = os.path.join(gapic_code_dir, 'src')
     proto_files = []
     for proto_path in src_proto_path:
         index = protoc_utils.find_google_dir_index(proto_path)
         for src_proto_file in protoc_utils.find_protos(
             [proto_path], excluded_proto_path):
             relative_proto_file = src_proto_file[index:]
             proto_files.append(relative_proto_file)
             dst_proto_file = os.path.join(final_output_dir,
                                           relative_proto_file)
             dst_proto_dir = os.path.dirname(dst_proto_file)
             if not os.path.exists(dst_proto_dir):
                 self.exec_command(['mkdir', '-p', dst_proto_dir])
             self.exec_command(['cp', src_proto_file, dst_proto_file])
     # Execute compileProtos from Docker image (a part of from google-gax)
     cwd = os.getcwd()
     os.chdir(gapic_code_dir)
     self.exec_command(['compileProtos', './src'])
     os.chdir(cwd)