@@ -71,18 +71,25 @@ def get_staging_dirs(
7171bigtable_default_version = "v2"
7272bigtable_admin_default_version = "v2"
7373
74+ is_fresh_admin_copy = False
75+ is_fresh_admin_v2_copy = False
76+ is_fresh_admin_docs_copy = False
77+
7478for library in get_staging_dirs (bigtable_default_version , "bigtable" ):
7579 s .move (library / "google/cloud/bigtable_v2" , excludes = ["**/gapic_version.py" ])
7680 s .move (library / "tests" )
7781 s .move (library / "scripts" )
7882
7983for library in get_staging_dirs (bigtable_admin_default_version , "bigtable_admin" ):
80- s .move (library / "google/cloud/bigtable_admin" , excludes = ["**/gapic_version.py" ])
81- s .move (library / "google/cloud/bigtable_admin_v2" , excludes = ["**/gapic_version.py" ])
84+ is_fresh_admin_copy = \
85+ s .move (library / "google/cloud/bigtable_admin" , excludes = ["**/gapic_version.py" ])
86+ is_fresh_admin_v2_copy = \
87+ s .move (library / "google/cloud/bigtable_admin_v2" , excludes = ["**/gapic_version.py" ])
8288 s .move (library / "tests" )
8389 s .move (library / "samples" )
8490 s .move (library / "scripts" )
85- s .move (library / "docs/bigtable_admin_v2" , destination = "docs/admin_client" )
91+ is_fresh_admin_docs_copy = \
92+ s .move (library / "docs/bigtable_admin_v2" , destination = "docs/admin_client" )
8693
8794s .remove_staging_dirs ()
8895
@@ -122,18 +129,20 @@ def get_staging_dirs(
122129
123130# Add overlay imports to top level __init__.py files in admin_v2 and admin at the end
124131# of each file, after the __all__ definition.
125- def add_overlay_to_init_py (init_py_location , import_statements ):
126- s .replace (
127- init_py_location ,
128- r"(?s)(^__all__ = \(.*\)$)" ,
129- r"\1\n\n" + import_statements
130- )
132+ def add_overlay_to_init_py (init_py_location , import_statements , should_add ):
133+ if should_add :
134+ s .replace (
135+ init_py_location ,
136+ r"(?s)(^__all__ = \(.*\)$)" ,
137+ r"\1\n\n" + import_statements
138+ )
131139
132140add_overlay_to_init_py (
133141 "google/cloud/bigtable_admin_v2/__init__.py" ,
134142 """from .overlay import * # noqa: F403
135143__all__ += overlay.__all__ # noqa: F405
136- """
144+ """ ,
145+ is_fresh_admin_v2_copy ,
137146)
138147
139148add_overlay_to_init_py (
@@ -142,7 +151,8 @@ def add_overlay_to_init_py(init_py_location, import_statements):
142151from google.cloud.bigtable_admin_v2.overlay import * # noqa: F401, F403
143152
144153__all__ += google.cloud.bigtable_admin_v2.overlay.__all__
145- """
154+ """ ,
155+ is_fresh_admin_copy ,
146156)
147157
148158# Replace all instances of BaseBigtableTableAdminClient/BaseBigtableAdminAsyncClient
@@ -225,27 +235,29 @@ def add_overlay_to_init_py(init_py_location, import_statements):
225235)
226236
227237# Add overlay types to types documentation
228- s .replace (
229- "docs/admin_client/types_.rst" ,
230- r"""(\.\. automodule:: google\.cloud\.bigtable_admin_v2\.types
231- :members:
232- :show-inheritance:)
233- """ ,
234- r"""\1
235-
236- .. automodule:: google.cloud.bigtable_admin_v2.overlay.types
237- :members:
238- :show-inheritance:
239- """
240- )
238+ if is_fresh_admin_docs_copy :
239+ s .replace (
240+ "docs/admin_client/types_.rst" ,
241+ r"""(\.\. automodule:: google\.cloud\.bigtable_admin_v2\.types
242+ :members:
243+ :show-inheritance:)
244+ """ ,
245+ r"""\1
246+
247+ .. automodule:: google.cloud.bigtable_admin_v2.overlay.types
248+ :members:
249+ :show-inheritance:
250+ """
251+ )
241252
242253# Add the oneof_message import into table.py for GcRule
243- s .replace (
244- "google/cloud/bigtable_admin_v2/types/table.py" ,
245- r"^(from google\.cloud\.bigtable_admin_v2\.types import .+)$" ,
246- r"""\1
247- from google.cloud.bigtable_admin_v2.utils import oneof_message""" ,
248- )
254+ if is_fresh_admin_v2_copy :
255+ s .replace (
256+ "google/cloud/bigtable_admin_v2/types/table.py" ,
257+ r"^(from google\.cloud\.bigtable_admin_v2\.types import .+)$" ,
258+ r"""\1
259+ from google.cloud.bigtable_admin_v2.utils import oneof_message""" ,
260+ )
249261
250262# Re-subclass GcRule in table.py
251263s .replace (
0 commit comments