Quote:
Originally Posted by rubeus
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.)