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.

136 lines
2.5 KiB

17 years ago
  1. #!/usr/local/bin/python
  2. import sys,string,time,os
  3. sys.path.append('../internal')
  4. import otros
  5. months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  6. 'August', 'September', 'October', 'November', 'December']
  7. for epnum in sys.argv[1:]:
  8. curep = string.atoi(epnum[:3])
  9. pix = open('../internal/epnames', 'r')
  10. for i in range(0, curep + 1):
  11. epname = pix.readline()[:-1]
  12. pix.close()
  13. if epname == '':
  14. epname = 'XXX'
  15. cureplong = '%03d' % curep
  16. if len(epnum) == 3:
  17. which = 'guide'
  18. else:
  19. which = 'extra'
  20. input = open(epnum, 'r')
  21. mtime = time.localtime(os.stat(epnum)[8]);
  22. mtime_str = '%s %d, %d' % (months[mtime[1]], mtime[2], mtime[0])
  23. try:
  24. os.unlink('#' + epnum + '.html')
  25. except:
  26. pass
  27. try:
  28. os.rename(epnum + '.html', '#' + epnum + '.html')
  29. except:
  30. pass
  31. output = open(epnum + '.html', 'w')
  32. output.write("""<html>
  33. <head>
  34. <title>Guide page: """ + '"' + epname + '"')
  35. if which == 'extra':
  36. output.write(' (scene in detail)')
  37. output.write("""</title>
  38. <link rev=made href="mailto:koreth@midwinter.com">
  39. <link rel=parent href="../eplist.html">
  40. </head>
  41. <body>
  42. """ + otros.pageheader(curep, which))
  43. if which == 'guide':
  44. output.write("""
  45. <p>
  46. <b>Contents:</b>
  47. <a href="#OV">Overview</a> -
  48. <a href="#BP">Backplot</a> -
  49. <a href="#UQ">Questions</a> -
  50. <a href="#AN">Analysis</a> -
  51. <a href="#NO">Notes</a> -
  52. <a href="#JS">JMS</a>
  53. <p>
  54. <hr>
  55. """)
  56. else:
  57. output.write("""
  58. <pre>
  59. </pre>
  60. """)
  61. wholefile = input.read()
  62. input.close()
  63. rewrite = open('@' + epnum, 'w')
  64. needsupdate = 0
  65. pieces = string.splitfields(wholefile, '@@@')
  66. output.write(pieces[0])
  67. rewrite.write(pieces[0])
  68. for piece in pieces[1:]:
  69. try:
  70. timestamp =string.atoi(piece[:string.index(piece, ' ')])
  71. except:
  72. timestamp = 0
  73. if timestamp == 0:
  74. needsupdate = 1
  75. timestamp = int(time.time())
  76. rewrite.write('@@@' + `timestamp`)
  77. rewrite.write(piece[string.index(piece, ' '):])
  78. else:
  79. rewrite.write('@@@' + piece)
  80. if timestamp >= time.time() - 14 * 60 * 60 * 24:
  81. timeval = time.localtime(timestamp)
  82. output.write('<strong>[[%d/%d]]</strong>' %
  83. (timeval[1], timeval[2]));
  84. output.write(piece[string.index(piece, ' '):])
  85. rewrite.close()
  86. if needsupdate:
  87. try:
  88. os.unlink('#' + epnum)
  89. except:
  90. pass
  91. os.rename(epnum, '#' + epnum)
  92. os.rename('@' + epnum, epnum)
  93. else:
  94. os.unlink('@' + epnum)
  95. output.write('<pre>\n\n</pre>\n' + otros.pagefooter(curep) + """
  96. <h5>
  97. Last update:
  98. """ + mtime_str + """
  99. </h5>
  100. </body>
  101. </html>
  102. """)
  103. output.close()
  104. print epnum