The Lurker's Guide to Babylon 5
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.2 KiB

17 years ago
  1. #!/usr/bin/python
  2. import os,sys,string,time
  3. def dumpfile(out, path):
  4. try:
  5. f = open(path, 'r')
  6. out.write(f.read())
  7. f.close()
  8. except:
  9. pass
  10. def cmptimes(i1, i2):
  11. if i1[1] < i2[1]:
  12. return -1
  13. if i1[1] > i2[1]:
  14. return 1
  15. return 0
  16. dirs = [ 'guide', 'synops' ]
  17. months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  18. 'August', 'September', 'October', 'November', 'December']
  19. outfile = open('lastmod-new.html', 'w')
  20. fp = open('internal/epnames', 'r')
  21. epnames = fp.readlines()
  22. fp.close()
  23. #
  24. # Spit out the page header.
  25. #
  26. dumpfile(outfile, 'internal/lu-header')
  27. mdate = time.localtime(time.time())
  28. outfile.write('%02d:%02d Pacific (US) time on %s %d, %d.\n' %
  29. (mdate[3], mdate[4], months[mdate[1]], mdate[2], mdate[0]))
  30. outfile.write("If that date isn't recent, you probably need to hit your reload button.\n")
  31. for dir in dirs:
  32. files = []
  33. dumpfile(outfile, 'internal/lu-header-' + dir)
  34. for file in os.listdir(dir):
  35. if file[0] != '0' and file[0] != '1' and file[0] != '5' or file[-4:] == 'html':
  36. continue
  37. path = dir + '/' + file
  38. #
  39. # Has the HTML been generated?
  40. #
  41. try:
  42. os.stat(path + '.html')
  43. except:
  44. continue
  45. #
  46. # Figure out when the file was touched last.
  47. #
  48. mtime = os.stat(path)[8]
  49. mdate = time.localtime(mtime)
  50. lastmod = '%02d/%02d/%02d' % (mdate[0] % 100, mdate[1],mdate[2])
  51. #
  52. # Figure out the file's episode name.
  53. #
  54. epnum = string.atoi(file[:3])
  55. epname = epnames[epnum][:-1]
  56. if len(file) != 3:
  57. epname = epname + ' (scene in detail)'
  58. #
  59. # Generate a list entry.
  60. #
  61. text = '%03d. %s: <a href="%s">%s</a><br>\n' % (
  62. epnum, lastmod, path + '.html', epname)
  63. files.append((epnum, mtime, text))
  64. #
  65. # Print a list sorted by date.
  66. #
  67. dumpfile(outfile, 'internal/lu-header-date')
  68. files.sort(cmptimes)
  69. files.reverse()
  70. for (epnum, mtime, text) in files:
  71. outfile.write(text)
  72. # dumpfile(outfile, 'internal/lu-header-epnum')
  73. #
  74. # Print a list sorted by episode number.
  75. #
  76. # files.sort()
  77. # for (epnum, mtime, text) in files:
  78. # outfile.write(text)
  79. dumpfile(outfile, 'internal/lu-footer-epnum')
  80. dumpfile(outfile, 'internal/lu-footer')
  81. outfile.close()
  82. os.unlink('lastmod.html')
  83. os.rename('lastmod-new.html', 'lastmod.html')