def _copy_template(template, destination_path): for repo in get_templates_repositories(): if repo.has_template(template): repo.copy_template(template, destination_path) return raise errors.TemplateMissingError(template)
def list_project_templates(): templates = [] for repository in get_templates_repositories(): repository.download() for template in repository.get_templates(): templates.append(TemplateSummary(template, repository)) templates = sorted(templates, key=lambda item: item.name) pretty_json = json.dumps([item.__dict__ for item in templates], indent=4) print(pretty_json)
def list_project_templates(as_json=False): templates = [] for repository in get_templates_repositories(): repository.download() for template in repository.get_templates(): templates.append(TemplateSummary(template, repository)) templates = sorted(templates, key=lambda item: item.name) if as_json: pretty_json = json.dumps([item.__dict__ for item in templates], indent=4) print(pretty_json) else: table = Texttable() table_data = [["Name", "Github", "Language"]] table_data.extend([[item.name, item.github, item.language] for item in templates]) table.add_rows(table_data) print(table.draw())
def _download_templates_repositories(): for repo in get_templates_repositories(): repo.download()