예제 #1
0
def obterPapersDeProfessor():
    professor = request.args.get('professor')

    if not professor:
        return Response(status=400)

    try:
        nomeArquivo = path.join("..", "data", "profs", "search",
                                professor) + ".csv"
        csvfile = open(nomeArquivo)
        saida = ''
        with csvfile as csvfile:
            papers = csv.reader(csvfile,
                                quotechar='"',
                                delimiter=',',
                                quoting=csv.QUOTE_ALL,
                                skipinitialspace=True)
            for row in papers:
                saida += row[0] + ',' + row[1] + ',' + row[2] + ',' + row[
                    3] + '\n'
    except IOError:
        return Response(status=404)
    except:
        return Response(status=500)
    return util.montaRespostaCSV(saida, "obterPapersDeProfessor")
예제 #2
0
def obterNumeroPublicacoesEmConferenciaEArea():
    conferencia = request.args.get('conferencia')
    area = request.args.get('area')

    if not conferencia or not area:
        return Response(status=400)

    numPublicacoes = 0

    try:
        with util.abreCSVAreaOutSufixo(area, "papers") as csvfile:
            papers = csv.reader(csvfile,
                                quotechar='"',
                                delimiter=',',
                                quoting=csv.QUOTE_ALL,
                                skipinitialspace=True)
            for row in papers:
                if (row[1] == conferencia.upper()):
                    numPublicacoes += 1
    except IOError:
        return Response(status=404)
    except:
        return Response(status=500)
    return util.montaRespostaCSV(str(numPublicacoes),
                                 "obterNumeroPublicacoesEmConferenciaEArea")
예제 #3
0
def obterNumerosProfessoresEmArea():
	area = request.args.get("area")
	if not area:
		return Response(status=400)
	try:
		arquivo = util.abreCSVAreaOutSufixo(area,"profs")
	except IOError:
		return Response(status=404)
	conteudoArquivo = arquivo.read()
	arquivo.close()
	return util.montaRespostaCSV(conteudoArquivo, "obterNumerosProfessoresEmArea")
예제 #4
0
def obterNumeroProfessoresEmAreaEDepartamento():
	area = request.args.get("area")
	departamento = request.args.get("departamento")
	if not area or not departamento:
		return Response(status=400)
	try:
		arquivo = util.abreCSVAreaOutSufixo(area,"profs")
	except IOError:
		return Response(status=404)
	achaDepartamento = filter(lambda linha: linha.find(departamento+",") == 0, arquivo)
	if not achaDepartamento:
		return Response(status=404)
	arquivo.close()
	return util.montaRespostaCSV(achaDepartamento[0], "obterNumeroProfessoresEmAreaEDepartamento")
예제 #5
0
def obterPapersEmArea():
    area = request.args.get('area')

    if not area:
        return Response(status=400)

    try:
        saida = ''
        with util.abreCSVAreaOutSufixo(area, "papers") as csvfile:
            papers = csv.reader(csvfile,
                                quotechar='"',
                                delimiter=',',
                                quoting=csv.QUOTE_ALL,
                                skipinitialspace=True)
            for row in papers:
                saida += row[0] + ',' + row[2] + ',' + row[3] + ',' + row[
                    4] + '\n'
    except IOError:
        return Response(status=404)
    except:
        return Response(status=500)
    return util.montaRespostaCSV(saida, "obterPapersEmArea")
예제 #6
0
def obterPapersEmAreaEmDepartamento():
    area = request.args.get('area')
    departamento = request.args.get('departamento')

    if not area or not departamento:
        return Response(status=400)

    try:
        retorno = ''
        with util.abreCSVAreaOutSufixo(area, "papers") as csvfile:
            papers = csv.reader(csvfile,
                                quotechar='"',
                                delimiter=',',
                                quoting=csv.QUOTE_ALL,
                                skipinitialspace=True)
            for row in papers:
                if (row[3] == departamento):
                    retorno += row[0] + ',' + row[2] + ',' + row[
                        3] + ',' + row[4] + '\n'
    except IOError:
        return Response(status=404)
    except:
        return Response(status=500)
    return util.montaRespostaCSV(retorno, "obterPapersEmAreaEmDepartamento")