@@ -71,6 +71,11 @@ def get_staging_dirs(
7171bigtable_default_version = "v2"
7272bigtable_admin_default_version = "v2"
7373
74+ # These flags are needed because certain post-processing operations
75+ # append things after a certain line of text, and can infinitely loop
76+ # in a Github PR. We use these flags to only do those operations
77+ # on fresh copies of files found in googleapis-gen, and not on user-submitted
78+ # changes.
7479is_fresh_admin_copy = False
7580is_fresh_admin_v2_copy = False
7681is_fresh_admin_docs_copy = False
@@ -128,7 +133,8 @@ def get_staging_dirs(
128133# --------------------------------------------------------------------------
129134
130135# Add overlay imports to top level __init__.py files in admin_v2 and admin at the end
131- # of each file, after the __all__ definition.
136+ # of each file, after the __all__ definition. These changes should only be done on fresh
137+ # copies of the __init__.py files.
132138def add_overlay_to_init_py (init_py_location , import_statements , should_add ):
133139 if should_add :
134140 s .replace (
@@ -226,44 +232,48 @@ def add_overlay_to_init_py(init_py_location, import_statements, should_add):
226232 ),
227233)
228234
229- # Change the subpackage for clients with overridden internal methods in them
230- # from service to overlay.service.
231- s .replace (
232- "docs/admin_client/bigtable_table_admin.rst" ,
233- r"^\.\. automodule:: google\.cloud\.bigtable_admin_v2\.services\.bigtable_table_admin$" ,
234- ".. automodule:: google.cloud.bigtable_admin_v2.overlay.services.bigtable_table_admin"
235- )
236-
237- # Add overlay types to types documentation
235+ # These changes should only be done on fresh copies of the .rst files
236+ # from googleapis-gen.
238237if is_fresh_admin_docs_copy :
238+ # Change the subpackage for clients with overridden internal methods in them
239+ # from service to overlay.service.
240+ s .replace (
241+ "docs/admin_client/bigtable_table_admin.rst" ,
242+ r"^\.\. automodule:: google\.cloud\.bigtable_admin_v2\.services\.bigtable_table_admin$" ,
243+ ".. automodule:: google.cloud.bigtable_admin_v2.overlay.services.bigtable_table_admin"
244+ )
245+
246+ # Add overlay types to types documentation
239247 s .replace (
240248 "docs/admin_client/types_.rst" ,
241249 r"""(\.\. automodule:: google\.cloud\.bigtable_admin_v2\.types
242- :members:
243- :show-inheritance:)
244- """ ,
250+ :members:
251+ :show-inheritance:)
252+ """ ,
245253 r"""\1
246254
247- .. automodule:: google.cloud.bigtable_admin_v2.overlay.types
248- :members:
249- :show-inheritance:
250- """
255+ .. automodule:: google.cloud.bigtable_admin_v2.overlay.types
256+ :members:
257+ :show-inheritance:
258+ """
251259 )
252260
253- # Add the oneof_message import into table.py for GcRule
261+ # These changes should only be done on a fresh copy of table.py
262+ # from googleapis-gen.
254263if is_fresh_admin_v2_copy :
264+ # Add the oneof_message import into table.py for GcRule
255265 s .replace (
256266 "google/cloud/bigtable_admin_v2/types/table.py" ,
257267 r"^(from google\.cloud\.bigtable_admin_v2\.types import .+)$" ,
258268 r"""\1
259- from google.cloud.bigtable_admin_v2.utils import oneof_message""" ,
269+ from google.cloud.bigtable_admin_v2.utils import oneof_message""" ,
260270 )
261271
262- # Re-subclass GcRule in table.py
263- s .replace (
264- "google/cloud/bigtable_admin_v2/types/table.py" ,
265- r"class GcRule\(proto\.Message\)\:" ,
266- "class GcRule(oneof_message.OneofMessage):" ,
267- )
272+ # Re-subclass GcRule in table.py
273+ s .replace (
274+ "google/cloud/bigtable_admin_v2/types/table.py" ,
275+ r"class GcRule\(proto\.Message\)\:" ,
276+ "class GcRule(oneof_message.OneofMessage):" ,
277+ )
268278
269279s .shell .run (["nox" , "-s" , "blacken" ], hide_output = False )
0 commit comments