1# -*- coding: utf-8 -*- 2import os 3ccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4template = """<!DOCTYPE html> 5<meta charset=utf-8> 6""" 7errors = { 8 "date-year-0000": "0000-12-09", 9 "date-month-00": "2002-00-15", 10 "date-month-13": "2002-13-15", 11 "date-0005-02-29": "0005-02-29", 12 "date-1969-02-29": "1969-02-29", 13 "date-1900-02-29": "1900-02-29", 14 "date-2100-02-29": "2100-02-29", 15 "date-2200-02-29": "2200-02-29", 16 "date-2014-02-29": "2014-02-29", 17 "date-day-04-31": "2002-04-31", 18 "date-day-06-31": "2002-06-31", 19 "date-day-09-31": "2002-09-31", 20 "date-day-11-31": "2002-11-31", 21 "date-day-01-32": "2002-01-32", 22 "date-day-03-32": "2002-03-32", 23 "date-day-05-32": "2002-05-32", 24 "date-day-07-32": "2002-07-32", 25 "date-day-08-32": "2002-08-32", 26 "date-day-10-32": "2002-10-32", 27 "date-day-12-32": "2002-12-32", 28 "date-iso8601-YYYYMMDD-no-hyphen": "20020929", 29 "date-leading-whitespace": " 2002-09-29", 30 "date-trailing-whitespace": "2002-09-29 ", 31 "date-month-one-digit": "2002-9-29", 32 "date-month-three-digits": "2002-011-29", 33 "date-year-three-digits": "782-09-29", 34 "date-day-one-digit": "2002-09-9", 35 "date-day-three-digits": "2002-11-009", 36 "date-day-missing-separator": "2014-0220", 37 "date-month-missing-separator": "201402-20", 38 "date-non-ascii-digit": "2002-09-29", 39 "date-trailing-U+0000": "2002-09-29�", 40 "date-trailing-pile-of-poo": "2002-09-29", 41 "date-wrong-day-separator": "2014-02:20", 42 "date-wrong-month-separator": "2014:02-20", 43 "date-year-negative": "-2002-09-29", 44 "date-leading-bom": "2002-09-29", 45 "global-date-and-time-60-minutes": "2011-11-12T00:60:00+08:00", 46 "global-date-and-time-60-seconds": "2011-11-12T00:00:60+08:00", 47 "global-date-and-time-2400": "2011-11-12T24:00:00+08:00", 48 "global-date-and-time-space-before-timezone": "2011-11-12T06:54:39 08:00", 49 "global-date-and-time-hour-one-digit": "2011-11-12T6:54:39-08:00", 50 "global-date-and-time-hour-three-digits": "2011-11-12T016:54:39-08:00", 51 "global-date-and-time-minutes-one-digit": "2011-11-12T16:4:39-08:00", 52 "global-date-and-time-minutes-three-digits": "2011-11-12T16:354:39-08:00", 53 "global-date-and-time-seconds-one-digit": "2011-11-12T16:54:9-08:00", 54 "global-date-and-time-seconds-three-digits": "2011-11-12T16:54:039-08:00", 55 "global-date-and-time-timezone-with-seconds": "2011-11-12T06:54:39-08:00:00", 56 "global-date-and-time-timezone-60-minutes": "2011-11-12T06:54:39-08:60", 57 "global-date-and-time-timezone-one-digit-hour": "2011-11-12T06:54:39-5:00", 58 "global-date-and-time-timezone-one-digit-minute": "2011-11-12T06:54:39-05:0", 59 "global-date-and-time-timezone-three-digit-hour": "2011-11-12T06:54:39-005:00", 60 "global-date-and-time-timezone-three-digit-minute": "2011-11-12T06:54:39-05:000", 61 "global-date-and-time-nbsp": "2011-11-12 14:54Z", 62 "global-date-and-time-missing-minutes-separator": "2011-11-12T1454Z", 63 "global-date-and-time-missing-seconds-separator": "2011-11-12T14:5439Z", 64 "global-date-and-time-wrong-minutes-separator": "2011-11-12T14-54Z", 65 "global-date-and-time-wrong-seconds-separator": "2011-11-12T14:54-39Z", 66 "global-date-and-time-lowercase-z": "2011-11-12T14:54z", 67 "global-date-and-time-with-both-T-and-space": "2011-11-12T 14:54Z", 68 "global-date-and-time-zero-digit-fraction": "2011-11-12T06:54:39.-08:00", 69 "global-date-and-time-four-digit-fraction": "2011-11-12T06:54:39.9291-08:00", 70 "global-date-and-time-bad-fraction-separator": "2011-11-12T14:54:39,929+0000", 71 "global-date-and-time-timezone-non-T-character": "2011-11-12+14:54Z", 72 "global-date-and-time-timezone-lowercase-t": "2011-11-12t14:54Z", 73 "global-date-and-time-timezone-multiple-spaces": "2011-11-12 14:54Z", 74 "global-date-and-time-timezone-offset-space-start": "2011-11-12T06:54:39.929 08:00", 75 "global-date-and-time-timezone-offset-colon-start": "2011-11-12T06:54:39.929:08:00", 76 "global-date-and-time-timezone-plus-2400": "2011-11-12T06:54:39-24:00", 77 "global-date-and-time-timezone-minus-2400": "2011-11-12T06:54:39-24:00", 78 "global-date-and-time-timezone-iso8601-two-digit": "2011-11-12T06:54:39-08", 79 "global-date-and-time-iso8601-hhmmss-no-colon": "2011-11-12T145439Z", 80 "global-date-and-time-iso8601-hhmm-no-colon": "2011-11-12T1454Z", 81 "global-date-and-time-iso8601-hh": "2011-11-12T14Z", 82 "year": "2006", 83 "yearless-date": "07-15", 84 "month": "2011-11", 85 "week": "2011-W46", 86 "time": "14:54:39", 87 "local-date-and-time": "2011-11-12T14:54", 88 "duration-P-form": "PT4H18M3S", 89 "duration-time-component": "4h 18m 3s", 90} 91 92warnings = { 93 "global-date-and-time-timezone-plus-1500": "2011-11-12T00:00:00+1500", 94 "global-date-and-time-timezone-minus-1300": "2011-11-12T00:00:00-1300", 95 "global-date-and-time-timezone-minutes-15": "2011-11-12T00:00:00+08:15", 96 "date-0214-09-29": "0214-09-29", 97 "date-20014-09-29": "20014-09-29", 98 "date-0004-02-29": "0004-02-29", 99 "date-year-five-digits": "12014-09-29", 100} 101 102non_errors = { 103 "date": "2002-09-29", 104 "date-2000-02-29": "2000-02-29", 105 "date-2400-02-29": "2400-02-29", 106 "date-1968-02-29": "1968-02-29", 107 "date-1900-02-28": "1900-02-28", 108 "date-2100-02-28": "2100-02-28", 109 "date-2200-02-28": "2200-02-28", 110 "date-2014-02-28": "2014-02-28", 111 "date-day-01-31": "2002-01-31", 112 "date-day-03-31": "2002-03-31", 113 "date-day-05-31": "2002-05-31", 114 "date-day-07-31": "2002-07-31", 115 "date-day-08-31": "2002-08-31", 116 "date-day-10-31": "2002-10-31", 117 "date-day-12-31": "2002-12-31", 118 "date-day-04-30": "2002-04-30", 119 "date-day-06-30": "2002-06-30", 120 "date-day-09-30": "2002-09-30", 121 "date-day-11-30": "2002-11-30", 122 "global-date-and-time-no-seconds": "2011-11-12T14:54Z", 123 "global-date-and-time-with-seconds": "2011-11-12T14:54:39+0000", 124 "global-date-and-time-with-one-digit-fraction": "2011-11-12T06:54:39.9-08:00", 125 "global-date-and-time-with-two-digit-fraction": "2011-11-12T06:54:39.92+07:00", 126 "global-date-and-time-with-three-digit-fraction": "2011-11-12T06:54:39.929-06:00", 127 "global-date-and-time-space": "2011-11-12 14:54Z", 128 "global-date-and-time-timezone": "2011-11-12T06:54:39+0900", 129 "global-date-and-time-timezone-30": "2011-11-12T06:54:39-0830", 130 "global-date-and-time-timezone-45": "2011-11-12T06:54:39-0845", 131 "global-date-and-time-timezone-with-colon": "2011-11-12T06:54:39-08:00", 132 "global-date-and-time-timezone-without-colon": "2011-11-12T06:54:39-0800", 133} 134 135for key in errors.keys(): 136 error = errors[key] 137 template_ins = template 138 template_del = template 139 template_ins += '<title>%s</title>\n' % key 140 template_del += '<title>%s</title>\n' % key 141 template_ins += '<ins datetime="%s"></ins>' % errors[key] 142 template_del += '<del datetime="%s"></del>' % errors[key] 143 ins_file = open(os.path.join(ccdir, "html/elements/ins/%s-novalid.html" % key), 'wb') 144 ins_file.write(template_ins) 145 ins_file.close() 146 del_file = open(os.path.join(ccdir, "html/elements/del/%s-novalid.html" % key), 'wb') 147 del_file.write(template_del) 148 del_file.close() 149 150for key in warnings.keys(): 151 non_error = warnings[key] 152 template_ins = template 153 template_del = template 154 template_ins += '<title>%s</title>\n' % key 155 template_del += '<title>%s</title>\n' % key 156 template_ins += '<ins datetime="%s"></ins>' % warnings[key] 157 template_del += '<del datetime="%s"></del>' % warnings[key] 158 ins_file = open(os.path.join(ccdir, "html/elements/ins/%s-haswarn.html" % key), 'wb') 159 ins_file.write(template_ins) 160 ins_file.close() 161 del_file = open(os.path.join(ccdir, "html/elements/del/%s-haswarn.html" % key), 'wb') 162 del_file.write(template_del) 163 del_file.close() 164 165ins_file = open(os.path.join(ccdir, "html/elements/ins/datetime-isvalid.html"), 'wb') 166del_file = open(os.path.join(ccdir, "html/elements/del/datetime-isvalid.html"), 'wb') 167ins_file.write(template + '<title>valid datetime</title>\n') 168del_file.write(template + '<title>valid datetime</title>\n') 169for key in non_errors.keys(): 170 non_error = non_errors[key] 171 ins_file.write('<ins datetime="%s"></ins> <!-- %s -->\n' % (non_errors[key], key)) 172 del_file.write('<del datetime="%s"></del> <!-- %s -->\n' % (non_errors[key], key)) 173ins_file.close() 174del_file.close() 175# vim: ts=4:sw=4 176