View Single Post
Old 12-19-2015, 01:40 PM   #118
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,739
Karma: 24031403
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by rubeus View Post
How can i read this file independet from the os to use it i my own plugin?
If you want to put your own cover file in:

Code:
C:\Users\rubeus\AppData\Local\sigil-ebook\sigil\cover.xhtml
you could access it independently of the OS as follows:

Code:
import os
 
def run(bk):
    cover_path = os.path.abspath(os.path.join(bk._w.usrsupdir, 'cover.xhtml'))
    print(cover_path)
    # Windows: C:\Users\doitsu\AppData\Local\sigil-ebook\sigil\cover.xhtml
    # Linux: /home/doitsu/.local/share/sigil-ebook/sigil/cover.xhtml
    print(os.path.isfile(cover_path))
You could also load it from within the plugin folder:

Code:
import os
 
def run(bk):
    cover_path = os.path.abspath(os.path.join(bk._w.plugin_dir, 'PluginName', 'cover.xhtml'))
    print(cover_path)
    # returns: C:\Users\doitsu\AppData\Local\sigil-ebook\sigil\plugins\PluginName\cover.xhtml 
    # returns: /home/doitsu/.local/share/sigil-ebook/sigil/plugins/PluginName/cover.xhtml
    print(os.path.isfile(cover_path))
(Replace PluginName with the actual plugin name.)
Doitsu is offline   Reply With Quote