2121from pathlib import Path
2222from typing import Optional
2323
24- from synthtool import _tracked_paths
25- from synthtool import log
26- from synthtool import metadata
27- from synthtool import shell
24+ from synthtool import _tracked_paths , metadata , shell
2825from synthtool .gcp import artman
26+ from synthtool .log import logger
2927from synthtool .sources import git
3028
3129GOOGLEAPIS_URL : str = git .make_repo_clone_url ("googleapis/googleapis" )
@@ -103,7 +101,7 @@ def _generate_code(
103101
104102 generator_dir = LOCAL_GENERATOR
105103 if generator_dir is not None :
106- log .debug (f"Using local generator at { generator_dir } " )
104+ logger .debug (f"Using local generator at { generator_dir } " )
107105
108106 # Run the code generator.
109107 # $ artman --config path/to/artman_api.yaml generate python_gapic
@@ -121,7 +119,7 @@ def _generate_code(
121119 f"Unable to find configuration yaml file: { (googleapis / config_path )} ."
122120 )
123121
124- log .debug (f"Running generator for { config_path } ." )
122+ logger .debug (f"Running generator for { config_path } ." )
125123
126124 if include_samples :
127125 if generator_args is None :
@@ -149,7 +147,7 @@ def _generate_code(
149147 f"Unable to find generated output of artman: { genfiles } ."
150148 )
151149
152- log .success (f"Generated code into { genfiles } ." )
150+ logger .success (f"Generated code into { genfiles } ." )
153151
154152 # Get the *.protos files and put them in a protos dir in the output
155153 if include_protos :
@@ -165,9 +163,9 @@ def _generate_code(
165163 os .makedirs (proto_output_path , exist_ok = True )
166164
167165 for i in proto_files :
168- log .debug (f"Copy: { i } to { proto_output_path / i .name } " )
166+ logger .debug (f"Copy: { i } to { proto_output_path / i .name } " )
169167 shutil .copyfile (i , proto_output_path / i .name )
170- log .success (f"Placed proto files into { proto_output_path } ." )
168+ logger .success (f"Placed proto files into { proto_output_path } ." )
171169
172170 if include_samples :
173171 samples_root_dir = None
@@ -209,10 +207,10 @@ def _clone_googleapis(self):
209207
210208 if LOCAL_GOOGLEAPIS :
211209 self ._googleapis = Path (LOCAL_GOOGLEAPIS ).expanduser ()
212- log .debug (f"Using local googleapis at { self ._googleapis } " )
210+ logger .debug (f"Using local googleapis at { self ._googleapis } " )
213211
214212 else :
215- log .debug ("Cloning googleapis." )
213+ logger .debug ("Cloning googleapis." )
216214 self ._googleapis = git .clone (GOOGLEAPIS_URL )
217215
218216 return self ._googleapis
@@ -223,12 +221,12 @@ def _clone_googleapis_private(self):
223221
224222 if LOCAL_GOOGLEAPIS :
225223 self ._googleapis_private = Path (LOCAL_GOOGLEAPIS ).expanduser ()
226- log .debug (
224+ logger .debug (
227225 f"Using local googleapis at { self ._googleapis_private } for googleapis-private"
228226 )
229227
230228 else :
231- log .debug ("Cloning googleapis-private." )
229+ logger .debug ("Cloning googleapis-private." )
232230 self ._googleapis_private = git .clone (GOOGLEAPIS_PRIVATE_URL )
233231
234232 return self ._googleapis_private
@@ -300,7 +298,7 @@ def _include_samples(
300298 test_files = googleapis_samples_dir .glob ("**/*.test.yaml" )
301299 os .makedirs (samples_test_dir , exist_ok = True )
302300 for i in test_files :
303- log .debug (f"Copy: { i } to { samples_test_dir / i .name } " )
301+ logger .debug (f"Copy: { i } to { samples_test_dir / i .name } " )
304302 shutil .copyfile (i , samples_test_dir / i .name )
305303
306304 # Download sample resources from sample_resources.yaml storage URIs.
@@ -321,7 +319,7 @@ def _include_samples(
321319 response = requests .get (uri , allow_redirects = True )
322320 download_path = samples_resources_dir / os .path .basename (uri )
323321 os .makedirs (samples_resources_dir , exist_ok = True )
324- log .debug (f"Download { uri } to { download_path } " )
322+ logger .debug (f"Download { uri } to { download_path } " )
325323 with open (download_path , "wb" ) as output : # type: ignore
326324 output .write (response .content )
327325
@@ -339,7 +337,7 @@ def _include_samples(
339337 "ruby" : "bundle exec ruby" ,
340338 }
341339 if language not in LANGUAGE_EXECUTABLES :
342- log .info ("skipping manifest gen" )
340+ logger .info ("skipping manifest gen" )
343341 return None
344342
345343 manifest_arguments = [
@@ -355,7 +353,7 @@ def _include_samples(
355353 if os .path .isfile (code_sample ):
356354 manifest_arguments .append (sample_path )
357355 try :
358- log .debug (f"Writing samples manifest { manifest_arguments } " )
356+ logger .debug (f"Writing samples manifest { manifest_arguments } " )
359357 shell .run (manifest_arguments , cwd = samples_root_dir )
360358 except (subprocess .CalledProcessError , FileNotFoundError ):
361- log .warning ("gen-manifest failed (sample-tester may not be installed)" )
359+ logger .warning ("gen-manifest failed (sample-tester may not be installed)" )
0 commit comments