[generate html for files
Olivier Schwander **20140524150427
Ignore-this: dc28587882eaa604d5c172968f32c848
] hunk ./pc.py 37
+ for item in items:
+ item.prepare()
+
hunk ./postcard/plugins.py 5
-from os.path import basename
+from os.path import basename, getsize
+
+from humanize import naturalsize
hunk ./postcard/plugins.py 30
+ def prepare(self):
+ pass
+
hunk ./postcard/plugins.py 121
-
+ self.count = len(paths)
+ self.names = [basename(path) for path in paths]
+
+ def prepare(self):
+ sizes = [ getsize(f) for f in self.paths ]
+ self.sizes = [ naturalsize(s) for s in sizes ]
+
hunk ./postcard/plugins.py 130
+
+ def html(self, index):
+ index.write("")
+
+ for i in range(self.count):
+ index.write("- ")
+ index.write("Download ")
+ index.write("{name}".format(name=self.names[i]))
+ index.write(" ({size})".format(size=self.sizes[i]))
+ index.write("
")
+
+ index.write("
")