tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

dl.py (4913B)


      1 # -*- coding: utf-8 -*-
      2 import os
      3 ccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
      4 template = """<!DOCTYPE html>
      5 <meta charset=utf-8>
      6 """
      7 
      8 errors = {
      9    "dl-in-p": "<p><dl><dt>text<dd>text</dl></p>",
     10    "header-in-dt": "<dl><dt><header>text</header><dd>text</dl>",
     11    "footer-in-dt": "<dl><dt><footer>text</footer><dd>text</dl>",
     12    "article-in-dt": "<dl><dt><article><h2>text</h2></article><dd>text</dl>",
     13    "aside-in-dt": "<dl><dt><aside><h2>text</h2></aside><dd>text</dl>",
     14    "nav-in-dt": "<dl><dt><nav><h2>text</h2></nav><dd>text</dl>",
     15    "section-in-dt": "<dl><dt><section><h2>text</h2></section><dd>text</dl>",
     16    "h1-in-dt": "<dl><dt><h1>text</h1><dd>text</dl>",
     17    "h2-in-dt": "<dl><dt><h2>text</h2><dd>text</dl>",
     18    "h3-in-dt": "<dl><dt><h3>text</h3><dd>text</dl>",
     19    "h4-in-dt": "<dl><dt><h4>text</h4><dd>text</dl>",
     20    "h5-in-dt": "<dl><dt><h5>text</h5><dd>text</dl>",
     21    "h6-in-dt": "<dl><dt><h6>text</h6><dd>text</dl>",
     22    "hgroup-in-dt": "<dl><dt><hgroup><h1>text</h1></hgroup><dd>text</dl>",
     23    "only-dt": "<dl><dt>1</dl>",
     24    "only-dd": "<dl><dd>a</dl>",
     25    "first-dd": "<dl><dd>a<dt>2<dd>b</dl>",
     26    "last-dt": "<dl><dt>1<dd>a<dt>2</dl>",
     27    "dd-in-template": "<dl><dt>1</dt><template><dd>a</dd></template></dl>",
     28    "dt-in-template": "<dl><template><dt>1</dt></template><dd>a</dl>",
     29    "dl-contains-text": "<dl><dt>1</dt>x</dl>",
     30    "dl-contains-text-2": "<dl><dt>1<dd>a</dd>x</dl>",
     31    "dl-contains-dl": "<dl><dt>1<dd>a</dd><dl></dl></dl>",
     32    # div
     33    "empty-div": "<dl><div></div></dl>",
     34    "empty-div-2": "<dl><div></div><div><dt>2<dd>b</div></dl>",
     35    "mixed-dt-dd-div": "<dl><dt>1<dd>a</dd><div><dt>2<dd>b</div></dl>",
     36    "mixed-div-dt-dd": "<dl><div><dt>1<dd>a</div><dt>2<dd>b</dd></dl>",
     37    "nested-divs": "<dl><div><div><dt>1<dd>a</div></div></dl>",
     38    "div-splitting-groups": "<dl><div><dt>1</div><div><dd>a</div></dl>",
     39    "div-splitting-groups-2": "<dl><div><dt>1<dd>a</div><div><dd>b</div></dl>",
     40    "div-splitting-groups-3": "<dl><div><dt>1</div><div><dt>2<dd>b</div></dl>",
     41    "div-contains-text": "<dl><div>x</div><dt>2<dd>b</div></dl>",
     42    "div-contains-dl": "<dl><div><dl></dl></div><dt>2<dd>b</div></dl>",
     43    "div-multiple-groups": "<dl><div><dt>1<dd>a<dt>2<dd>a<dd>b<dt>3<dt>4<dt>5<dd>a</div></dl>",
     44 }
     45 
     46 non_errors_in_head = {
     47    "parent-template-in-head": "<template><dl><dt>text<dd>text</dl></template>",
     48 }
     49 
     50 non_errors = {
     51    "basic": "<dl><dt>text<dd>text</dl>",
     52    "empty": "<dl></dl>",
     53    "empty-dt-dd": "<dl><dt><dd></dl>",
     54    "multiple-groups": "<dl><dt>1<dd>a<dt>2<dd>a<dd>b<dt>3<dt>4<dt>5<dd>a</dl>",
     55    "header-in-dd": "<dl><dt>text<dd><header>text</header></dl>",
     56    "footer-in-dd": "<dl><dt>text<dd><footer>text</footer></dl>",
     57    "article-in-dd": "<dl><dt>text<dd><article><h2>text</h2></article></dl>",
     58    "aside-in-dd": "<dl><dt>text<dd><aside><h2>text</h2></aside></dl>",
     59    "nav-in-dd": "<dl><dt>text<dd><nav><h2>text</h2></nav></dl>",
     60    "section-in-dd": "<dl><dt>text<dd><section><h2>text</h2></section></dl>",
     61    "h1-in-dd": "<dl><dt>text<dd><h1>text</h1></dl>",
     62    "h2-in-dd": "<dl><dt>text<dd><h2>text</h2></dl>",
     63    "h3-in-dd": "<dl><dt>text<dd><h3>text</h3></dl>",
     64    "h4-in-dd": "<dl><dt>text<dd><h4>text</h4></dl>",
     65    "h5-in-dd": "<dl><dt>text<dd><h5>text</h5></dl>",
     66    "h6-in-dd": "<dl><dt>text<dd><h6>text</h6></dl>",
     67    "p-in-dt": "<dl><dt><p>1<p>1<dd>a</dl>",
     68    "dl-in-dt": "<dl><dt><dl><dt>1<dd>a</dl><dd>b</dl>",
     69    "dl-in-dd": "<dl><dt>1<dd><dl><dt>2<dd>a</dl></dl>",
     70    "interactive": "<dl><dt><a href='#'>1</a><dd><a href='#'>a</a></dl>",
     71    "script": "<dl><script></script></dl>",
     72    "dt-script-dd": "<dl><dt>1</dt><script></script><dd>a</dl>",
     73    "dt-template-dd": "<dl><dt>1</dt><template></template><dd>a</dl>",
     74    # div
     75    "div-basic": "<dl><div><dt>1<dd>a</div></dl>",
     76    "div-script": "<dl><div><dt>1<dd>a</div><script></script></dl>",
     77    "div-script-2": "<dl><div><dt>1</dt><script></script><dd>a</div></dl>",
     78    "div-template": "<dl><div><dt>1<dd>a</div><template></template></dl>",
     79    "div-template-2": "<dl><div><dt>1</dt><template></template><dd>a</div></dl>",
     80    "div-multiple-groups": "<dl><div><dt>1<dd>a</div><div><dt>2<dd>a<dd>b</div><div><dt>3<dt>4<dt>5<dd>a</div></dl>",
     81 }
     82 
     83 for key in errors.keys():
     84    template_error = template
     85    template_error += '<title>invalid %s</title>\n' % key
     86    template_error += errors[key]
     87    file = open(os.path.join(ccdir, "html/elements/dl/%s-novalid.html" % key), 'w')
     88    file.write(template_error)
     89    file.close()
     90 
     91 file = open(os.path.join(ccdir, "html/elements/dl/dl-isvalid.html"), 'w')
     92 file.write(template + '<title>valid dl</title>\n')
     93 for key in non_errors_in_head.keys():
     94    file.write('%s <!-- %s -->\n' % (non_errors_in_head[key], key))
     95 file.write('<body>\n')
     96 for key in non_errors.keys():
     97    file.write('%s <!-- %s -->\n' % (non_errors[key], key))
     98 file.close()
     99 # vim: ts=4:sw=4