Beispiel #1
0
def parseconfig(filename, doxref, dohtml, tree, debugfile):
  # Build the contents of an html <select> and open search links
  # for all trees encountered.
  browsetree = ''
  options = '<select id="tree">'
  opensearch = ''

  dxrconfig = dxr.load_config(filename)

  for treecfg in dxrconfig.trees:
    # if tree is set, only index/build this section if it matches
    if tree and treecfg.tree != tree:
        continue

    browsetree += '<a href="%s">Browse <b>%s</b> source</a> ' % (treecfg.tree, treecfg.tree)
    options += '<option value="' + treecfg.tree + '">' + treecfg.tree + '</option>'
    opensearch += '<link rel="search" href="opensearch-' + treecfg.tree + '.xml" type="application/opensearchdescription+xml" '
    opensearch += 'title="' + treecfg.tree + '" />\n'
    WriteOpenSearch(treecfg.tree, treecfg.hosturl, treecfg.virtroot, treecfg.wwwdir)
    indextree(treecfg, doxref, dohtml, debugfile)

  # Generate index page with drop-down + opensearch links for all trees
  indexhtml = dxrconfig.getTemplateFile('dxr-index-template.html')
  indexhtml = string.Template(indexhtml).safe_substitute(**treecfg.__dict__)
  indexhtml = indexhtml.replace('$BROWSETREE', browsetree)
  if len(dxrconfig.trees) > 1:
    options += '</select>'
  else:
    options = ''
  indexhtml = indexhtml.replace('$OPTIONS', options)
  indexhtml = indexhtml.replace('$OPENSEARCH', opensearch)
  index = open(os.path.join(dxrconfig.wwwdir, 'index.html'), 'w')
  index.write(indexhtml)
  index.close()
Beispiel #2
0
def parseconfig(filename, doxref, dohtml, tree, debugfile):
  # Build the contents of an html <select> and open search links
  # for all trees encountered.
  # Note: id for CSS, name for form "get" value in query
  browsetree = ''
  options = '<select id="tree" name="tree">'
  opensearch = ''

  dxrconfig = dxr.load_config(filename)

  # Copy in the static stuff
  shutil.rmtree(dxrconfig.wwwdir + "/",  True)
  shutil.copytree(dxrconfig.dxrroot + "/www/", dxrconfig.wwwdir,  False)
  
  # Fill and copy templates that we'll need for search
  # Note not everything is filled, just properties from dxrconfig
  # See dxr/__init__.py:DxrConfig.getTemplateFile for details
  os.mkdir(dxrconfig.wwwdir + "/dxr_server/templates")
  for tmpl in ("dxr-search-header.html", "dxr-search-footer.html"):
    with open(dxrconfig.wwwdir + "/dxr_server/templates/" + tmpl, 'w') as f:
      f.write(dxrconfig.getTemplateFile(tmpl))
  
  # Substitute trees directly into the dxr_server sources, so no need for config
  with open(dxrconfig.wwwdir + "/dxr_server/__init__.py", "r") as f:
    t = string.Template(f.read())
  with open(dxrconfig.wwwdir + "/dxr_server/__init__.py", "w") as f:
    f.write(t.safe_substitute(trees = repr([tree] if tree else [cfg.tree for cfg in dxrconfig.trees]),
                              virtroot = dxrconfig.virtroot))
  
  # Copy in to www the dxr tokenizer, and cross fingers that this binary
  # works on the server we deploy to :)
  shutil.copy(dxrconfig.dxrroot + "/sqlite/libdxr-code-tokenizer.so", dxrconfig.wwwdir + "/dxr_server/")

  for treecfg in dxrconfig.trees:
    # if tree is set, only index/build this section if it matches
    if tree and treecfg.tree != tree:
        continue

    treecfg.virtroot = dxrconfig.virtroot
    browsetree += '<a href="%s">Browse <b>%s</b> source</a> ' % (treecfg.tree, treecfg.tree)
    options += '<option value="' + treecfg.tree + '">' + treecfg.tree + '</option>'
    opensearch += '<link rel="search" href="opensearch-' + treecfg.tree + '.xml" type="application/opensearchdescription+xml" '
    opensearch += 'title="' + treecfg.tree + '" />\n'
    WriteOpenSearch(treecfg.tree, treecfg.hosturl, treecfg.virtroot, treecfg.wwwdir)
    indextree(treecfg, doxref, dohtml, debugfile)

  # Generate index page with drop-down + opensearch links for all trees
  indexhtml = dxrconfig.getTemplateFile('dxr-index-template.html')
  indexhtml = string.Template(indexhtml).safe_substitute(**treecfg.__dict__)
  indexhtml = indexhtml.replace('$BROWSETREE', browsetree)
  if len(dxrconfig.trees) > 1:
    options += '</select>'
  else:
    options = '<input type="hidden" id="tree" value="' + treecfg.tree + '">'
  indexhtml = indexhtml.replace('$OPTIONS', options)
  indexhtml = indexhtml.replace('$OPENSEARCH', opensearch)
  index = open(os.path.join(dxrconfig.wwwdir, 'index.html'), 'w')
  index.write(indexhtml)
  index.close()
Beispiel #3
0
def parseconfig(filename, doxref, dohtml, tree, debugfile):
    # Build the contents of an html <select> and open search links
    # for all trees encountered.
    # Note: id for CSS, name for form "get" value in query
    browsetree = ''
    options = '<select id="tree" name="tree">'
    opensearch = ''

    dxrconfig = dxr.load_config(filename)

    for treecfg in dxrconfig.trees:
        # if tree is set, only index/build this section if it matches
        if tree and treecfg.tree != tree:
            continue

        treecfg.virtroot = dxrconfig.virtroot
        browsetree += '<a href="%s">Browse <b>%s</b> source</a> ' % (
            treecfg.tree, treecfg.tree)
        options += '<option value="' + treecfg.tree + '">' + treecfg.tree + '</option>'
        opensearch += '<link rel="search" href="opensearch-' + treecfg.tree + '.xml" type="application/opensearchdescription+xml" '
        opensearch += 'title="' + treecfg.tree + '" />\n'
        WriteOpenSearch(treecfg.tree, treecfg.hosturl, treecfg.virtroot,
                        treecfg.wwwdir)
        indextree(treecfg, doxref, dohtml, debugfile)

    # Generate index page with drop-down + opensearch links for all trees
    indexhtml = dxrconfig.getTemplateFile('dxr-index-template.html')
    indexhtml = string.Template(indexhtml).safe_substitute(**treecfg.__dict__)
    indexhtml = indexhtml.replace('$BROWSETREE', browsetree)
    if len(dxrconfig.trees) > 1:
        options += '</select>'
    else:
        options = '<input type="hidden" id="tree" value="' + treecfg.tree + '">'
    indexhtml = indexhtml.replace('$OPTIONS', options)
    indexhtml = indexhtml.replace('$OPENSEARCH', opensearch)
    index = open(os.path.join(dxrconfig.wwwdir, 'index.html'), 'w')
    index.write(indexhtml)
    index.close()
Beispiel #4
0
def parseconfig(filename, doxref, dohtml, tree, debugfile):
    # Build the contents of an html <select> and open search links
    # for all trees encountered.
    # Note: id for CSS, name for form "get" value in query
    browsetree = ''
    options = '<select id="tree" name="tree">'
    opensearch = ''

    dxrconfig = dxr.load_config(filename)

    # Copy in the static stuff
    shutil.rmtree(dxrconfig.wwwdir + "/", True)
    shutil.copytree(dxrconfig.dxrroot + "/www/", dxrconfig.wwwdir, False)

    # Fill and copy templates that we'll need for search
    # Note not everything is filled, just properties from dxrconfig
    # See dxr/__init__.py:DxrConfig.getTemplateFile for details
    os.mkdir(dxrconfig.wwwdir + "/dxr_server/templates")
    for tmpl in ("dxr-search-header.html", "dxr-search-footer.html"):
        with open(dxrconfig.wwwdir + "/dxr_server/templates/" + tmpl,
                  'w') as f:
            f.write(dxrconfig.getTemplateFile(tmpl))

    # Substitute trees directly into the dxr_server sources, so no need for config
    with open(dxrconfig.wwwdir + "/dxr_server/__init__.py", "r") as f:
        t = string.Template(f.read())
    with open(dxrconfig.wwwdir + "/dxr_server/__init__.py", "w") as f:
        f.write(
            t.safe_substitute(trees=repr(
                [tree] if tree else [cfg.tree for cfg in dxrconfig.trees]),
                              virtroot=dxrconfig.virtroot))

    # Copy in to www the dxr tokenizer, and cross fingers that this binary
    # works on the server we deploy to :)
    shutil.copy(dxrconfig.dxrroot + "/sqlite/libdxr-code-tokenizer.so",
                dxrconfig.wwwdir + "/dxr_server/")

    for treecfg in dxrconfig.trees:
        # if tree is set, only index/build this section if it matches
        if tree and treecfg.tree != tree:
            continue

        treecfg.virtroot = dxrconfig.virtroot
        browsetree += '<a href="%s">Browse <b>%s</b> source</a> ' % (
            treecfg.tree, treecfg.tree)
        options += '<option value="' + treecfg.tree + '">' + treecfg.tree + '</option>'
        opensearch += '<link rel="search" href="opensearch-' + treecfg.tree + '.xml" type="application/opensearchdescription+xml" '
        opensearch += 'title="' + treecfg.tree + '" />\n'
        WriteOpenSearch(treecfg.tree, treecfg.hosturl, treecfg.virtroot,
                        treecfg.wwwdir)
        indextree(treecfg, doxref, dohtml, debugfile)

    # Generate index page with drop-down + opensearch links for all trees
    indexhtml = dxrconfig.getTemplateFile('dxr-index-template.html')
    indexhtml = string.Template(indexhtml).safe_substitute(**treecfg.__dict__)
    indexhtml = indexhtml.replace('$BROWSETREE', browsetree)
    if len(dxrconfig.trees) > 1:
        options += '</select>'
    else:
        options = '<input type="hidden" id="tree" value="' + treecfg.tree + '">'
    indexhtml = indexhtml.replace('$OPTIONS', options)
    indexhtml = indexhtml.replace('$OPENSEARCH', opensearch)
    index = open(os.path.join(dxrconfig.wwwdir, 'index.html'), 'w')
    index.write(indexhtml)
    index.close()
Beispiel #5
0
#!/usr/bin/env python

import sys
sys.path.append('..')

import ConfigParser
import imp, dxr

# Read in the configuration for the test
tests = ConfigParser.ConfigParser()
tests.read('tests.ini')
testname = sys.argv[1]

# Get the database data for the tree
dxrcfg = dxr.load_config(tests.get(testname, 'dxrconfig'))
if len(dxrcfg.trees) != 1:
    raise Exception('Database can only have one tree')
tree = dxrcfg.trees[0]
big_blob = dxr.load_big_blob(tree)
# For the purposes of language data, dxr.languages.language_data too
big_blob['dxr.language_data'] = dxr.languages.language_data

# Load the checker data
load_data = open(tests.get(testname, 'checkdb'))
check_blob = eval(load_data.read())
load_data.close()

errors = []


def verifyDatabase(output, standard, should_be_present, string):