Exemplo n.º 1
0
def nevowify(filename, linkrel, ext, url, templ, options=None, outfileGenerator=tree.getOutputFileName):
    if options is None:
        options = {}
    pclass = options['pageclass']
    pclass = reflect.namedObject(pclass)
    page = pclass(docFactory=loaders.htmlfile(filename))
    s = page.renderString()
    s = ____wait(s)

    newFilename = outfileGenerator(filename, ext)

    if options.has_key('nolore'):
        f = open(newFilename, 'w')
        f.write(s)
        f.close()
        return

    doc = parseStringAndReport(s)
    clonedNode = templ.cloneNode(1)
    tree.munge(doc, clonedNode, linkrel, os.path.dirname(filename), filename, ext,
               url, options, outfileGenerator)
    tree.makeSureDirectoryExists(newFilename)
    f = open(newFilename, 'wb')
    clonedNode.writexml(f)
    f.close()
Exemplo n.º 2
0
def nevowify(filename,
             linkrel,
             ext,
             url,
             templ,
             options=None,
             outfileGenerator=tree.getOutputFileName):
    if options is None:
        options = {}
    pclass = options['pageclass']
    pclass = reflect.namedObject(pclass)
    page = pclass(docFactory=loaders.htmlfile(filename))
    s = page.renderString()
    s = ____wait(s)

    newFilename = outfileGenerator(filename, ext)

    if options.has_key('nolore'):
        open(newFilename, 'w').write(s)
        return

    doc = parseStringAndReport(s)
    clonedNode = templ.cloneNode(1)
    tree.munge(doc, clonedNode, linkrel, os.path.dirname(filename), filename,
               ext, url, options, outfileGenerator)
    tree.makeSureDirectoryExists(newFilename)
    clonedNode.writexml(open(newFilename, 'wb'))
Exemplo n.º 3
0
 def test_makeSureDirectoryExists(self):
     dirname = os.path.join("tmp", 'nonexistentdir')
     if os.path.exists(dirname):
         os.rmdir(dirname)
     self.failIf(os.path.exists(dirname), "Hey: someone already created the dir")
     filename = os.path.join(dirname, 'newfile')
     tree.makeSureDirectoryExists(filename)
     self.failUnless(os.path.exists(dirname), 'should have created dir')
     os.rmdir(dirname)
Exemplo n.º 4
0
 def test_makeSureDirectoryExists(self):
     dirname = os.path.join("tmp", 'nonexistentdir')
     if os.path.exists(dirname):
         os.rmdir(dirname)
     self.failIf(os.path.exists(dirname), "Hey: someone already created the dir")
     filename = os.path.join(dirname, 'newfile')
     tree.makeSureDirectoryExists(filename)
     self.failUnless(os.path.exists(dirname), 'should have created dir')
     os.rmdir(dirname)