View Single Post
Old 04-13-2020, 12:31 PM   #4
carmenchu
Groupie
carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.
 
Posts: 193
Karma: 266070
Join Date: Dec 2010
Location: Spain
Device: Win10,Win11,Ubuntu,PockbookLux44
Quote:
Originally Posted by DiapDealer View Post
As to why you're getting different output to the plugin runner window with what appears to be cosmetic-only changes: debug-printing to the plugin runner window is tricky at best. If your plugin is working as expected; trust that. Otherwise if you need to use extensive debug prints, it's almost always best to find a way to test your code outside of Sigil.

All output/results of a Sigil plugin are delivered back to Sigil's plugin window as an xml file. That xml file is then parsed and displayed via the plugin runner window. Depending on when, in the process, output with tags is printed, that output can actually get rendered by Qt instead displayed in its "raw" state.
Thanks! As a matter of fact, after
Spoiler:
Code:
from sigil_bs4 import BeautifulSoup
# from sigil_bs4.builder._lxml import LXMLTreeBuilderForXML 
...
    new_metadata = metadata_soup.decodexml(indent_level=0, formatter='minimal', indent_chars="  ")
    print(new_metadata)
    
    bk.setmetadataxml(new_metadata)
    print('\nDone')

my code prints normal. Looks like BeautifulSoup must dump back all the structure into place for thinks to behave as expected--one learns.

BTW, can one define preferences as either
Code:
prefs['mine'] = {source1:'value1',source2:'value2',...}
prefs['mine'] = [('source1','value1'),('source2','value2'),...]
or must it be a single string/list to be processed after loading?
carmenchu is offline   Reply With Quote