1313# limitations under the License.
1414
1515import json
16- from typing import List , Optional
1716from pathlib import Path
1817import shutil
1918
3231 "default_version"
3332)
3433
35- # This is a customized version of the s.get_staging_dirs() function from synthtool to
36- # cater for copying 2 different folders from googleapis-gen
37- # which are workflows and workflows/executions
38- # Source https://github.com/googleapis/synthtool/blob/master/synthtool/transforms.py#L280
39- def get_staging_dirs (
40- default_version : Optional [str ] = None , sub_directory : Optional [str ] = None
41- ) -> List [Path ]:
42- """Returns the list of directories, one per version, copied from
43- https://github.com/googleapis/googleapis-gen. Will return in lexical sorting
44- order with the exception of the default_version which will be last (if specified).
45-
46- Args:
47- default_version (str): the default version of the API. The directory for this version
48- will be the last item in the returned list if specified.
49- sub_directory (str): if a `sub_directory` is provided, only the directories within the
50- specified `sub_directory` will be returned.
51-
52- Returns: the empty list if no file were copied.
53- """
54-
55- staging = Path ("owl-bot-staging" )
56-
57- if sub_directory :
58- staging /= sub_directory
59-
60- if staging .is_dir ():
61- # Collect the subdirectories of the staging directory.
62- versions = [v .name for v in staging .iterdir () if v .is_dir ()]
63- # Reorder the versions so the default version always comes last.
64- versions = [v for v in versions if v != default_version ]
65- versions .sort ()
66- if default_version is not None :
67- versions += [default_version ]
68- dirs = [staging / v for v in versions ]
69- for dir in dirs :
70- s ._tracked_paths .add (dir )
71- return dirs
72- else :
73- return []
74-
75-
76- for library in get_staging_dirs (default_version , "executions" ):
77- # Make sure this library is named 'google-cloud-workflows'
78- s .replace (
79- library / "google/**/*.py" , "google-cloud-workflows-executions" , "google-cloud-workflows"
80- )
81- s .move ([library ], excludes = ["**/gapic_version.py" , "docs/index.rst" ])
82-
83- # move workflows after executions, since we want to use "workflows" for the name
84- for library in get_staging_dirs (default_version , "workflows" ):
34+ for library in s .get_staging_dirs (default_version ):
8535 if clean_up_generated_samples :
8636 shutil .rmtree ("samples/generated_samples" , ignore_errors = True )
8737 clean_up_generated_samples = False
88- s .move ([library ], excludes = ["**/gapic_version.py" , "docs/index.rst" ])
8938
39+ s .move ([library ], excludes = ["**/gapic_version.py" ])
9040s .remove_staging_dirs ()
9141
9242# ----------------------------------------------------------------------------
@@ -98,7 +48,7 @@ def get_staging_dirs(
9848 microgenerator = True ,
9949 versions = gcp .common .detect_versions (path = "./google" , default_first = True ),
10050)
101- s .move (templated_files , excludes = [".coveragerc" , ".github/release-please.yml" , "docs/index.rst" ])
51+ s .move (templated_files , excludes = [".coveragerc" , ".github/release-please.yml" ])
10252
10353python .py_samples (skip_readmes = True )
10454
0 commit comments