|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 |
| -import glob |
16 | 15 | import os
|
17 | 16 | import xml.etree.ElementTree as ET
|
18 | 17 | import re
|
@@ -166,80 +165,6 @@ def version_from_maven_metadata(metadata: str) -> Optional[str]:
|
166 | 165 | return None
|
167 | 166 |
|
168 | 167 |
|
169 |
| -def _common_generation( |
170 |
| - service: str, |
171 |
| - version: str, |
172 |
| - library: Path, |
173 |
| - package_pattern: str, |
174 |
| - suffix: str = "", |
175 |
| - destination_name: str = None, |
176 |
| - cloud_api: bool = True, |
177 |
| - diregapic: bool = False, |
178 |
| - preserve_gapic: bool = False, |
179 |
| -): |
180 |
| - """Helper function to execution the common generation cleanup actions. |
181 |
| -
|
182 |
| - Fixes headers for protobuf classes and generated gRPC stub services. Copies |
183 |
| - code and samples to their final destinations by convention. Runs the code |
184 |
| - formatter on the generated code. |
185 |
| -
|
186 |
| - Args: |
187 |
| - service (str): Name of the service. |
188 |
| - version (str): Service API version. |
189 |
| - library (Path): Path to the temp directory with the generated library. |
190 |
| - package_pattern (str): Package name template for fixing file headers. |
191 |
| - suffix (str, optional): Suffix that the generated library folder. The |
192 |
| - artman output differs from bazel's output directory. Defaults to "". |
193 |
| - destination_name (str, optional): Override the service name for the |
194 |
| - destination of the output code. Defaults to the service name. |
195 |
| - preserve_gapic (bool, optional): Whether to preserve the gapic directory |
196 |
| - prefix. Default False. |
197 |
| - """ |
198 |
| - |
199 |
| - if destination_name is None: |
200 |
| - destination_name = service |
201 |
| - |
202 |
| - cloud_prefix = "cloud-" if cloud_api else "" |
203 |
| - package_name = package_pattern.format(service=service, version=version) |
204 |
| - proto_library_name = f"proto-google-{cloud_prefix}{service}-{version}" |
205 |
| - grpc_library_name = f"grpc-google-{cloud_prefix}{service}-{version}" |
206 |
| - gapic_library_name = f"gapic-google-{cloud_prefix}{service}-{version}" |
207 |
| - fix_proto_headers(library / f"{proto_library_name}{suffix}") |
208 |
| - fix_grpc_headers(library / f"{grpc_library_name}{suffix}", package_name) |
209 |
| - |
210 |
| - if preserve_gapic: |
211 |
| - s.copy( |
212 |
| - [library / f"{gapic_library_name}{suffix}/src"], |
213 |
| - f"{gapic_library_name}/src", |
214 |
| - required=True, |
215 |
| - ) |
216 |
| - else: |
217 |
| - s.copy( |
218 |
| - [library / f"{gapic_library_name}{suffix}/src"], |
219 |
| - f"google-{cloud_prefix}{destination_name}/src", |
220 |
| - required=True, |
221 |
| - ) |
222 |
| - |
223 |
| - s.copy( |
224 |
| - [library / f"{grpc_library_name}{suffix}/src"], |
225 |
| - f"{grpc_library_name}/src", |
226 |
| - # For REST-only clients, like java-compute, gRPC artifact does not exist |
227 |
| - required=(not diregapic), |
228 |
| - ) |
229 |
| - s.copy( |
230 |
| - [library / f"{proto_library_name}{suffix}/src"], |
231 |
| - f"{proto_library_name}/src", |
232 |
| - required=True, |
233 |
| - ) |
234 |
| - |
235 |
| - if preserve_gapic: |
236 |
| - format_code(f"{gapic_library_name}/src") |
237 |
| - else: |
238 |
| - format_code(f"google-{cloud_prefix}{destination_name}/src") |
239 |
| - format_code(f"{grpc_library_name}/src") |
240 |
| - format_code(f"{proto_library_name}/src") |
241 |
| - |
242 |
| - |
243 | 168 | def _merge_release_please(destination_text: str):
|
244 | 169 | handle_gh_release_key = "handleGHRelease"
|
245 | 170 | branches_key = "branches"
|
|
0 commit comments