def render_tree(self, jagare, repo, organization, tree, version, team): ret = [] readme = None for d in tree: data = Obj() if d['type'] == 'tree': data.url = get_url(organization, repo, view='repos.view', team=team, version=version, path=d['path']) elif d['type'] == 'blob': data.url = get_url(organization, repo, view='repos.blob', team=team, version=version, path=d['path']) if d['name'].startswith('README.'): readme, content_type, _ = format_content(jagare, repo, d['path'], version=version) if content_type != 'file': readme = None elif d['type'] == 'submodule': data.url = get_submodule_url(d['submodule'], d['sha']) d['name'] = '%s@%s' % (d['name'], d['sha'][:10]) data.name = d['name'] data.sha = d['sha'] data.type = d['type'] data.ago = format_time(d['commit']['committer']['ts']) data.message = d['commit']['message'][:150] data.commit = d['commit']['sha'] data.path = d['path'] ret.append(data) return readme, ret
def get_tree_with_content(jagare, tree, repo, organization, render=True, version='master'): ret = [] for d in tree: data = Obj() if d['type'] == 'blob': data.content, data.content_type, data.length = format_content( jagare, repo, d['path'], render=render, version=version, \ ) else: continue data.name = d['name'] data.sha = d['sha'] data.type = d['type'] data.ago = format_time(d['commit']['committer']['ts']) data.message = d['commit']['message'][:150] data.commit = d['commit']['sha'] data.path = d['path'] ret.append(data) return ret