Logo Search packages:      
Sourcecode: uicilibris version File versions  Download package

def uicilibris::w2book::wiki2book::toFile (   self,
  fileName,
  report = None 
)
write self contents to a file
imports and writes necessary images
@param report if True, this method will output a few messages on sys.stderr;
if report is a callback function, this function will be called with one parameter.

Definition at line 113 of file w2book.py.

                                           :
        """
        write self contents to a file
        imports and writes necessary images
        @param report if True, this method will output a few messages on sys.stderr;
        if report is a callback function, this function will be called with one parameter.
        """
        outfile=open(fileName, "w")
        outfile.write("%s" %self)
        outfile.close()
        path=os.path.dirname(fileName)
        href=""
        for img in self.imageSet:
            completeUrl="http://%s/index.php/File:%s" %(self.baseAddress, img)
            page=url.urlopen(completeUrl)
            soup=BeautifulSoup(page.read())
            divs=soup.findAll("div", id="file")
            for div in divs:
                a=div.find("a")
                href=a["href"]
                if report==True:
                    print >> sys.stderr, "'%s'" %href
                elif callable(report):
                    report("'%s'" %href)
            imgData=url.urlopen("http://%s/%s" %(self.host,href))
            imgFile=open(os.path.join(path,img),"w")
            imgFile.write(imgData.read())
            imgFile.close()
        return
    
            

Generated by  Doxygen 1.6.0   Back to index