View Single Post
Old 10-31-2014, 02:12 PM   #23
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,904
Karma: 6120478
Join Date: Nov 2009
Device: many
Hi,

You seem to either only be working on a set of files without an opf (or that have no entries in the opf).

The calls you make to read and write the files are only correct for files ***not*** part of the manifest in the opf.

Code:
        def applySelect(self):

                if self.flagAll.get() == True:
                        for (ID, href) in self.bk.text_iter():
                                html = self.bk.readotherfile(ID)
                                r = Remove(html)
                                html_new = r.get_html()
                                self.bk.writeotherfile(ID,html_new)
If your html files are actually included in the manifest of the opf, the correct way to access these files is via the calls setup to do just that:

Code:
    def readfile(self, id):
        # returns the contents of the file with manifest id  (text files are utf-8 encoded)
        return self._w.readfile(id)

    def writefile(self, id, data):
        # writes data to a currently existing file pointed to by the manifest id
        self._w.writefile(id, data)
whereas you used code to read and write files that are **not** part of the manifest.

Code:
# reading / writing / adding / deleting other ebook files that DO NOT exist in the opf manifest

    def readotherfile(self, book_href):
        # returns the contents of the file pointed to by the ebook href
        return self._w.readotherfile(book_href)

    def writeotherfile(self, book_href, data):
        # writes data to a currently existing file pointed to by the ebook href
        self._w.writeotherfile(book_href, data)
The ONLY way this would work is that either your opf file is broken or non-existant or not being parsed properly.

So if that code truly works for you, and if the files you edit are actually part of the manifest in the opf, then something is very broken that needs to be fixed. So could you please post just the opf file for a book this code works on so that I can track down why the opf is not being parsed properly and get it fixed in the next release of Sigil.

Thanks,

KevinH

Quote:
Originally Posted by kbanelas View Post
Hello!!

I know it's possible I have been an obstinate because of to want doing this plugin but now the work have been made. I'll upload my little script smoothRemove for everybody.
Now in this version of plugin 0.1 you'll be able to realize a complete remove formatting but with the peculiarity of preserve the italics, underline, bold, list and headings tags.
Remember that it's about an special remove formatting. Everything the rest of tags will be removed

ATTENTION: Don't use this plugin with the cover, so if you have one, don't select a complete smoothRemove, only select the files in that you are interested.

See you soon

Last edited by KevinH; 10-31-2014 at 02:15 PM.
KevinH is offline   Reply With Quote