View Single Post
Old 11-15-2016, 05:15 AM   #2
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,763
Karma: 24088559
Join Date: Dec 2010
Device: Kindle PW2
I wasn't able to reproduce your problem with on my 64bit Windows 10 machine.

I used the following edit plugin code:

Spoiler:
Code:
#!/usr/bin/env python
import sys

try:
    from sigil_bs4 import BeautifulSoup
    print('Sigil bs4 imported')
except:
    from bs4 import BeautifulSoup
    print('regular bs4 imported')

def run(bk):
    print('Launcher version: ', bk.launcher_version())
    print('Python version: ', sys.version, '\n')
    html = bk.readfile('Section0001.xhtml')
    soup = BeautifulSoup(html, 'html.parser')
    
    for tag in soup():
        for attribute in ["lang", "id", "dir", "name" "link"]:
            del tag[attribute]
        
    print(str(soup))
    
    return 0

def main():
    print('I reached main when I should not have\n')
    return -1

if __name__ == "__main__":
    sys.exit(main())


with this Section0001.xhtml file:

Spoiler:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
</head>

<body lang="en">
  <p id="test">Lorem ipsum</p>
</body>
</html>


The output was:

Spoiler:
Code:
Status: success

Sigil bs4 imported
Launcher version:  20160909
Python version:  3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<p>Lorem ipsum</p>
</body>
</html>


BTW, you should be able to import sigil_bs4 even if you use an external interpreter. If you disable Use Bundled Python, you should still get the following message:

Code:
Sigil bs4 imported
Doitsu is offline   Reply With Quote