<commit_before>from flask import jsonify, request, g, abort, url_for, current_app,send_file
from app.api import api
from app.exceptions import CustomError
from app.utils import toJson
import os
import sys
import uuid
import shutil
import argparse
import tempfile
from io import StringIO,BytesIO

from ..bugtracker.abstract import AbstractTrack
from ..bugtracker.github import Github
from datetime import datetime

#================================================================================
@api.route('/projects/', methods=['GET'])
def get_projects():
    return toJson(_list_project())

#================================================================================
@api.route('/projects/', methods=['POST'])
def create_project():
    post = request.json
    if post["provider"] == "github":
        project = Github(post["track_url"], "github")
        project.url = post["track_url"]
        project.name = post["name"]
        project.description = post["description"]
        project.date_created = datetime.now()
        project.write()
        return toJson(post)
    else:
        raise CustomError("{} provider isn't avaible".format(post["provider"]))

    return True

@api.route('/projects/<int:iid>', methods=['GET'])
def get_project(iid):
    return(toJson(_get_project(iid).to_dict()))
    
@api.route('/projects/<int:iid>', methods=['DELETE'])
def delete_project(iid):
    try :
        name = _list_project()[iid - 1]
    except :
        raise CustomError("projects {} didn't exist, sorry".format(iid))<commit_msg>/projects/ return full information on project no just file name<commit_after>from flask import jsonify, request, g, abort, url_for, current_app,send_file
from app.api import api
from app.exceptions import CustomError
from app.utils import toJson
import os
import sys
import uuid
import shutil
import argparse
import tempfile
from io import StringIO,BytesIO

from ..bugtracker.abstract import AbstractTrack
from ..bugtracker.github import Github
from datetime import datetime

#================================================================================
@api.route('/projects/', methods=['GET'])
def get_projects():
    ret_list = list()
    for i in range(0, len(_list_project())):
        ret_list.append(_get_project(i).to_dict())
    return toJson(ret_list)

#================================================================================
@api.route('/projects/', methods=['POST'])
def create_project():
    post = request.json
    if post["provider"] == "github":
        project = Github(post["track_url"], "github")
        project.url = post["track_url"]
        project.name = post["name"]
        project.description = post["description"]
        project.date_created = datetime.now()
        project.write()
        return toJson(post)
    else:
        raise CustomError("{} provider isn't avaible".format(post["provider"]))

    return True

@api.route('/projects/<int:iid>', methods=['GET'])
def get_project(iid):
    return(toJson(_get_project(iid).to_dict()))
    
@api.route('/projects/<int:iid>', methods=['DELETE'])
def delete_project(iid):
    try :
        name = _list_project()[iid - 1]
    except :
        raise CustomError("projects {} didn't exist, sorry".format(iid))
{'fraction_non_alphanumeric': 0.2224622030237581, 'fraction_numerical': 0.0009256402344955261, 'mean_word_length': 4.560891938250429, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '487224', 'n_tokens_mistral': 899, 'n_tokens_neox': 882, 'n_words': 226}