MCPcopy Create free account
hub / github.com/ActiveState/code / createIndex

Method createIndex

recipes/Python/271246_pyAlbumpy/recipe-271246.py:157–185  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

155 fp.close()
156
157 def createIndex(self):
158 # Create the index file
159 self.indexFile = "index.htm"
160 os.chdir(self.dirName)
161 fp = open(self.indexFile,"w")
162 temp = """<html>
163 <head>
164 <title>%s</title>
165 <link rel="stylesheet" href="%s/styles.css">
166 </head>
167 <body>
168 <center><h2>%s</h2></center>
169 <table align="center"><tr>
170 """ % (self.title, self.slideName, self.title)
171 self.count = 0
172 for x in self.files:
173 image_size = Image.open(x).size
174 file_size = int(os.stat(x)[6]/1024)
175 width = int(image_size[0])
176 height = int(image_size[1])
177 if self.count == 0 :
178 temp = temp + "</tr><tr>"
179 temp = temp + "<td valign=\"bottom\" align=\"center\" style=\"text-align:center\"><a href=\"" + self.slideName + "/" + self.slideName + x + ".htm" + "\"><img src=\"" + self.tnDir + "/" + x + "\"><br>" + x + "</a><br><span style=\"color:gray\"><small>" + str(width) + "&times;" + str(height) + ", " + str(file_size) + "kB</small></span> </td>"
180 self.count = self.count + 1
181 if self.count == 4:
182 self.count = 0
183 temp = temp + "</tr></table>\n<p style=\"padding-left:10px\"><small>Created using <a href=\"http://premshree.resource-locator.com/python/pyAlbum.py\"><small>pyAlbum.py</small></a></small></p>\n</body>\n</html>"
184 fp.write(temp)
185 fp.close()
186
187 def exifInfo(self, fileName):
188 os.chdir(self.dirName)

Callers 1

recipe-271246.pyFile · 0.80

Calls 6

strFunction · 0.85
chdirMethod · 0.80
openFunction · 0.50
openMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected