2020from synthtool import gcp
2121from synthtool .languages import python
2222
23- gapic = gcp .GAPICBazel ()
2423common = gcp .CommonTemplates ()
25- versions = ["v1p1beta1" , "v1p2beta1" , "v1p4beta1" , "v1p5beta1" , "v1" ]
2624
27- excludes = [ "setup.py" , "nox*.py" , "README.rst" , "docs/conf.py" , "docs/index.rst" ]
25+ default_version = "v1"
2826
29- # ----------------------------------------------------------------------------
30- # Generate asset GAPIC layer
31- # ----------------------------------------------------------------------------
32- for version in versions :
33- library = gapic .py_library (
34- service = "asset" ,
35- version = version ,
36- bazel_target = f"//google/cloud/asset/{ version } :asset-{ version } -py" ,
27+ for library in s .get_staging_dirs (default_version ):
28+ # Fix import of 'osconfig' type
29+ s .replace (
30+ library / f"google/cloud/asset_{ library .name } /types/assets.py" ,
31+ f"from google\.cloud\.osconfig\.{ library .name } import inventory_pb2 as inventory" ,
32+ f"from google.cloud.osconfig_{ library .name } import Inventory"
3733 )
3834
39- s .move (library , excludes = excludes )
35+ s .replace (
36+ library / f"google/cloud/asset_{ library .name } /types/assets.py" ,
37+ "message=inventory\.Inventory," ,
38+ "message=Inventory,"
39+ )
4040
41- # Fix import of 'osconfig' type
42- s .replace (
43- "google/cloud/asset_v1/types/assets.py" ,
44- "from google\.cloud\.osconfig\.v1 import inventory_pb2 as inventory" ,
45- "from google.cloud.osconfig_v1 import Inventory"
46- )
41+ # Remove broken `parse_asset_path` method
42+ # The resource pattern is '*' which breaks the regex match
43+ s .replace (
44+ library / "google/cloud/**/client.py" ,
45+ """@staticmethod
46+ def parse_asset_path.*?@staticmethod""" ,
47+ """@staticmethod""" ,
48+ flags = re .MULTILINE | re .DOTALL
49+ )
4750
48- s .replace (
49- "google/cloud/asset_v1/types/assets .py" ,
50- "message=inventory\.Inventory, " ,
51- "message=Inventory, "
52- )
51+ s .replace (
52+ library / "google/cloud/**/async_client .py" ,
53+ """parse_asset_path = staticmethod\(AssetServiceClient\.parse_asset_path\)"" " ,
54+ " "
55+ )
5356
54- # Remove broken `parse_asset_path` method
55- # The resource pattern is '*' which breaks the regex match
56- s .replace (
57- "google/cloud/**/client.py" ,
58- """@staticmethod
59- def parse_asset_path.*?@staticmethod""" ,
60- """@staticmethod""" ,
61- flags = re .MULTILINE | re .DOTALL
62- )
57+ s .replace (
58+ library / "tests/unit/**/test_asset_service.py" ,
59+ """def test_parse_asset_path.*?def""" ,
60+ """def""" ,
61+ flags = re .MULTILINE | re .DOTALL ,
62+ )
63+
64+ excludes = ["setup.py" , "nox*.py" , "README.rst" , "docs/conf.py" , "docs/index.rst" ]
65+ s .move (library , excludes = excludes )
66+
67+ s .remove_staging_dirs ()
6368
64- s .replace (
65- "google/cloud/**/async_client.py" ,
66- """parse_asset_path = staticmethod\(AssetServiceClient\.parse_asset_path\)""" ,
67- ""
68- )
69- s .replace (
70- "tests/unit/**/test_asset_service.py" ,
71- """def test_parse_asset_path.*?def""" ,
72- """def""" ,
73- flags = re .MULTILINE | re .DOTALL ,
74- )
7569# ----------------------------------------------------------------------------
7670# Add templated files
7771# ----------------------------------------------------------------------------
@@ -92,4 +86,4 @@ def parse_asset_path.*?@staticmethod""",
9286# https://github.com/googleapis/gapic-generator-python/issues/525
9387s .replace ("noxfile.py" , '[\" \' ]-W[\" \' ]' , '# "-W"' )
9488
95- s .shell .run (["nox" , "-s" , "blacken" ], hide_output = False )
89+ s .shell .run (["nox" , "-s" , "blacken" ], hide_output = False )
0 commit comments