From ff3c57773ed34c41490f19871c4cc12ddc196cc0 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Wed, 11 Nov 2020 17:11:20 -0500 Subject: [PATCH] chore: clean up synth replacements (#161) - Remove those which no longer match. - Apply '_GAPIC_LIBRARY_VERSION' tweak from PR #150. Closes #155. Closes #156. --- synth.py | 50 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/synth.py b/synth.py index 8a2fed1c7..21100c749 100644 --- a/synth.py +++ b/synth.py @@ -45,40 +45,28 @@ s.move(library / "google/cloud/bigtable_admin_v2") s.move(library / "tests") -s.replace( - [ - "google/cloud/bigtable_admin_v2/gapic/bigtable_instance_admin_client.py", - "google/cloud/bigtable_admin_v2/gapic/bigtable_table_admin_client.py", - ], - "'google-cloud-bigtable-admin'", - "'google-cloud-bigtable'", -) - -s.replace( - "google/**/*.py", - "from google\.cloud\.bigtable\.admin_v2.proto", - "from google.cloud.bigtable_admin_v2.proto", -) +# Work around non-standard installations -s.replace( - ["google/cloud/bigtable_admin_v2/__init__.py"], - " __doc__ = bigtable_instance_admin_client." - "BigtableInstanceAdminClient.__doc__\n", - " __doc__ = (\n" - " bigtable_instance_admin_client.BigtableInstanceAdminClient." - "__doc__)\n", -) - -s.replace( - ["google/cloud/bigtable_v2/gapic/bigtable_client.py"], - "if ``true_mutations`` is empty, and at most\n\n\s*100000.", - "if ``true_mutations`` is empty, and at most 100000.", -) +admin_clients = [ + "google/cloud/bigtable_admin_v2/gapic/bigtable_instance_admin_client.py", + "google/cloud/bigtable_admin_v2/gapic/bigtable_table_admin_client.py", +] s.replace( - ["google/cloud/bigtable_v2/gapic/bigtable_client.py"], - "if ``false_mutations`` is empty, and at most\n\n\s*100000.", - "if ``false_mutations`` is empty, and at most 100000.", + admin_clients, + """\ +_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution\( + 'google-cloud-bigtable-admin', +\).version +""", + """\ +try: + _GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( + "google-cloud-bigtable" + ).version +except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GAPIC_LIBRARY_VERSION = None +""" ) # ----------------------------------------------------------------------------