All pastes #983994 Raw Edit

Miguel/badPicAlbumCode

public python v1 · immutable
·published 2008-04-13 20:30 UTC
rendered paste body
def makePicAlbum(path):    myFile = "PicAlbum.html"    longName = os.path.join(path, myFile)    f = open(longName, "wt")    f.write("<html><head><title>PicAlbum</title></head>")    f.write("<table>")    images = getImgRecurse(path)    imgTable = genImgTable(images)    for rows in imgTable:        f.write("<tr>")        for img in rows:            f.write("<td>"+img+"</td>")        f.write("</tr>")    f.write("</table")    f.write("</html")    f.close()    def getImgRecurse(path):     names = os.listdir(path)    imgList = []    for name in names:        longname = os.path.join(path, name)        imgList.append(longname)    return imgListdef genImgTable(images):    imgList = images[:]    rows = []    aRow = []    while len(imgList) > 0:        image = imgList[0]        if len(aRow) == 5:            rows.append(aRow)            aRow = []        aRow.append(image)        imgList.remove(image)    rows.append(aRow)    return rows