Permalink
Browse files

more refined comparison function

  • Loading branch information...
1 parent 7944118 commit 6626b45b1205955c3ae4beb434696c2e849b4d0d @dz committed Mar 3, 2009
Showing with 8 additions and 10 deletions.
  1. +8 −10 chisel.py
View
@@ -57,10 +57,17 @@ def get_tree(source):
'year': year,
'month': month,
'day': day,
+ 'filename': name,
})
f.close()
return files
+def compare_entries(x, y):
+ result = cmp(-x['epoch'], -y['epoch'])
+ if result == 0:
+ return -cmp(x['filename'], y['filename'])
+ return result
+
def write_file(url, data):
path = DESTINATION + url
dirs = os.path.dirname(path)
@@ -89,19 +96,10 @@ def detail_pages(f, e):
for file in f:
write_file(file['url'], template.render(entry=file))
-@step
-def date_indices(f, e):
- """
- Generate date indices for all year, month, days
- permutations. Example: "/2009/02/"
- """
- pass
-
-
def main():
print "Chiseling..."
print "\tReading files...",
- files = sorted(get_tree(SOURCE), cmp=lambda x,y: cmp(-x['epoch'], -y['epoch']))
+ files = sorted(get_tree(SOURCE), cmp=compare_entries)
env = jinja2.Environment(loader=jinja2.FileSystemLoader(TEMPLATE_PATH), **TEMPLATE_OPTIONS)
print "Done."
print "\tRunning steps..."

0 comments on commit 6626b45

Please sign in to comment.