in tools/connector.py [0:0]
def copy_connector_template(connector_name: str, destination: str):
"""Copy job template files to jobs directory."""
try:
shutil.copytree(
src=TEMPLATES_DIR,
dst=Path(destination) / connector_name,
)
except FileExistsError:
raise ValueError(f"Connector with name {connector_name} already exists.")
# generate CI config for connector
template_loader = jinja2.FileSystemLoader(TEMPLATES_DIR)
template_env = jinja2.Environment(loader=template_loader)
try:
ci_workflow_template = template_env.get_template(CI_WORKFLOW_TEMPLATE_NAME)
except jinja2.exceptions.TemplateNotFound:
raise FileNotFoundError(
f"{CI_WORKFLOW_TEMPLATE_NAME} must be in {TEMPLATES_DIR}"
)
ci_workflow_text = ci_workflow_template.render(connector_name=connector_name)
with open(Path(destination) / connector_name / CI_WORKFLOW_TEMPLATE_NAME, "w") as f:
f.write(ci_workflow_text)