Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add option to specify local googleapis directory #100

Merged
merged 3 commits into from
Oct 19, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions synthtool/gcp/gapic_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@


class GAPICGenerator:
def __init__(self):
self._clone_googleapis()

def py_library(self, service: str, version: str, **kwargs) -> Path:
"""
Generates the Python Library files using artman/GAPIC
Expand Down Expand Up @@ -58,6 +55,7 @@ def _generate_code(
language,
config_path=None,
artman_output_name=None,
googleapis_directory=None,
private=False,
):
# map the language to the artman argument and subdir of genfiles
Expand All @@ -75,16 +73,21 @@ def _generate_code(
gapic_language_arg, gen_language = GENERATE_FLAG_LANGUAGE[language]

# Determine which googleapis repo to use
if not private:
googleapis = self.googleapis
if googleapis_directory:
googleapis = Path(googleapis_directory).expanduser()
log.debug(f"Using local googleapis at: {googleapis}")
else:
googleapis = self.googleapis_private

if googleapis is None:
raise RuntimeError(
f"Unable to generate {config_path}, the googleapis repository"
"is unavailable."
)
self._clone_googleapis()
if not private:
googleapis = self.googleapis
else:
googleapis = self.googleapis_private

if googleapis is None:
raise RuntimeError(
f"Unable to generate {config_path}, the googleapis repository"
"is unavailable."
)

# Run the code generator.
# $ artman --config path/to/artman_api.yaml generate python_gapic
Expand All @@ -99,7 +102,7 @@ def _generate_code(

if not (googleapis / config_path).exists():
raise FileNotFoundError(
f"Unable to find configuration yaml file: {config_path}."
f"Unable to find configuration yaml file: {(googleapis / config_path)}."
)

log.debug(f"Running generator for {config_path}.")
Expand Down