Beispiel #1
0
"""
#search has been queried
else:
	#begin open file
	tableStream = open("MOCK_DATA.csv", "r")
	tableString = tableStream.read()
	tableStream.close()
	#end open file
	
	dataTable = dataToTable.makeList(tableString)
	
	#the result table
	finalTable = dataTable
	
	#search by name
	if "findByName" in form and not(form.getvalue("qString") is None):
		if form.getvalue("searchType") == "first":
			finalTable = searchByName(finalTable, form.getvalue("qString"), 1)
		elif form.getvalue("searchType") == "last":
			finalTable = searchByName(finalTable, form.getvalue("qString"), 2)
		elif form.getvalue("searchType") == "email":
			finalTable = searchByName(finalTable, form.getvalue("qString"), 3)
	#search by state
	if "findByState" in form:
		finalTable = searchByName(finalTable, form.getvalue("qState"), 4)
	
	print "<table>\n" + dataToTable.makeTableBody(finalTable) + \
	"</table>"

print htmlFuncts.endPage()
Beispiel #2
0
    print "Average words per line: " + str(count2 / lineCount2)
    print "</td>"

    print "</tr>"

    print "<tr>"

    #### First one
    print "<td>"
    print form.getvalue("qBook")

    print makeTabs(5) + '<table border="1">'

    print "Unique words: " + str(unique) + "\n"

    print dataToTable.makeTableBody(dictToList(tally, count))

    print makeTabs(5) + "</table>"
    print "</td>"

    #### Second one
    print "<td>"
    print form.getvalue("qBook2")
    print makeTabs(5) + '<table border="1">'

    print "Unique words: " + str(unique2)

    print dataToTable.makeTableBody(dictToList(tally2, count2))

    print makeTabs(5) + "</table>"
    print "</td>"
Beispiel #3
0
        # displays only certain amount of elements
    page = 0
    if "page" in form:
        page = int(form.getvalue("page"))
    resPerPage = 10
    if "resPerPage" in form:
        if form.getvalue("resPerPage").isdigit():
            resPerPage = int(form.getvalue("resPerPage"))

            # save space
    tableStart = resPerPage * page

    # result table
    print "<table>\n" + dataToTable.makeTableHeader(header) + dataToTable.makeTableBody(
        finalTable[tableStart : tableStart + resPerPage]
    ) + "</table>"

    # previous and next links

    # prev
    if page > 0:
        print "<a id='prev' href='lab13.py?page=" + str(page - 1) + "&resPerPage=" + str(
            resPerPage
        ) + cgiParts + "'>prev</a>"

        # next
    if resPerPage % (len(finalTable) / float(resPerPage)) == 0:
        if (page + 1) < math.ceil(len(finalTable) / resPerPage):
            print "<a id='next' href='lab13.py?page=" + str(page + 1) + "&resPerPage=" + str(
                resPerPage
    #displays only certain amount of elements
    page = 0
    if "page" in form:
        page = int(form.getvalue("page"))
    resPerPage = 10
    if "resPerPage" in form:
        if form.getvalue("resPerPage").isdigit():
            resPerPage = int(form.getvalue("resPerPage"))

    #save space
    tableStart = resPerPage * page

    #result table
    print "<table>\n" + \
    dataToTable.makeTableHeader(header) + \
    dataToTable.makeTableBody(
    finalTable[tableStart:tableStart + resPerPage]) + \
    "</table>"

    #previous and next links

    #prev
    if page > 0:
        print "<a id='prev' href='lab13.py?page=" + str(page - 1) + \
        "&resPerPage=" + str(resPerPage) + cgiParts + "'>prev</a>"

    #next
    if resPerPage % (len(finalTable) / float(resPerPage)) == 0:
        if (page + 1) < math.ceil(len(finalTable) / resPerPage):
            print "<a id='next' href='lab13.py?page=" + \
            str(page + 1) + \
            "&resPerPage=" + str(resPerPage) + cgiParts + "'>next</a>"