<commit_before>import os
import base64
from flask import Flask , request, render_template
import nbconvert.nbconvert as nbconvert
import requests
from nbformat import current as nbformat
from flask import Flask, redirect, abort
import re
import github as gh
from gist import render_content

app = Flask(__name__)
github = gh.Github()

@app.route('/')
def render_url():
    return 'you are at root'

@app.route('/<user>/')
def user(user):
    return github.get_user(user).name

@app.route('/<user>/<repo>/')
def repo(user,repo):
    return github.get_user(user).get_repo(repo).url


@app.route('/<user>/<repo>/<tree>/<branch>/<path:subfile>')
def file(user,repo,tree,branch, subfile):
    #we don't care about tree or branch now...
    base  = "You are trying to access the file : %(file)s, from the %(repo)s repository of %(name)s"
    user = github.get_user(user)
    repo = user.get_repo(repo)

    master = repo.master_branch
    branch = [b for b in repo.get_branches() if b.name == master][0]

    headtree = repo.get_git_tree(branch.commit.sha)



    formated = base % { 'name':user.name,'repo':repo.url, 'file':subfile}
    e = rwt(repo, branch.commit.sha, subfile.strip('/').split('/'))
    if e.type == 'blob' :
        f = repo.get_git_blob(e.sha)
        return render_content(base64.decodestring(f.content))
    else :
        return 'this is a tree'



#recursively walk tree....
def rwt(repo,sha,path):
    subpath = path[1:]
    key = path[0]
    nodes = repo.get_git_tree(sha).tree
    for n in nodes :
        if n.path == key:
            if n.type == 'tree':
                return rwt(repo, n.sha, subpath)
            else :
                return n


if __name__ == '__main__':
    # Bind to PORT if defined, otherwise default to 5000.
    port = int(os.environ.get('PORT', 5000))
    debug = os.path.exists('.debug')
    if debug :
        print 'DEBUG MODE IS ACTIVATED !!!'
    else :
        print 'debug is not activated'
    app.run(host='0.0.0.0', port=port, debug=debug)<commit_msg>returun on tree<commit_after>import os
import base64
from flask import Flask , request, render_template
import nbconvert.nbconvert as nbconvert
import requests
from nbformat import current as nbformat
from flask import Flask, redirect, abort
import re
import github as gh
from gist import render_content

app = Flask(__name__)
github = gh.Github()

@app.route('/')
def render_url():
    return 'you are at root'

@app.route('/<user>/')
def user(user):
    return github.get_user(user).name

@app.route('/<user>/<repo>/')
def repo(user,repo):
    return github.get_user(user).get_repo(repo).url


@app.route('/<user>/<repo>/<tree>/<branch>/<path:subfile>')
def file(user,repo,tree,branch, subfile):
    #we don't care about tree or branch now...
    base  = "You are trying to access the file : %(file)s, from the %(repo)s repository of %(name)s"
    user = github.get_user(user)
    repo = user.get_repo(repo)

    master = repo.master_branch
    branch = [b for b in repo.get_branches() if b.name == master][0]

    headtree = repo.get_git_tree(branch.commit.sha)



    formated = base % { 'name':user.name,'repo':repo.url, 'file':subfile}
    e = rwt(repo, branch.commit.sha, subfile.strip('/').split('/'))
    if e.type == 'blob' :
        f = repo.get_git_blob(e.sha)
        return render_content(base64.decodestring(f.content))
    else :
        return '\n'.join([n.path for n on e])



#recursively walk tree....
def rwt(repo,sha,path):
    nodes = repo.get_git_tree(sha).tree
    if(len(path) == 1):
        return nodes
    subpath = path[1:]
    key = path[0]
    for n in nodes :
        if n.path == key:
            if n.type == 'tree':
                return rwt(repo, n.sha, subpath)
            else :
                return n


if __name__ == '__main__':
    # Bind to PORT if defined, otherwise default to 5000.
    port = int(os.environ.get('PORT', 5000))
    debug = os.path.exists('.debug')
    if debug :
        print 'DEBUG MODE IS ACTIVATED !!!'
    else :
        print 'debug is not activated'
    app.run(host='0.0.0.0', port=port, debug=debug)
{'fraction_non_alphanumeric': 0.14338145338879374, 'fraction_numerical': 0.009542451676045999, 'mean_word_length': 2.9921875, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7407638', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1375, 'n_words': 378}