View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0016947 | Scribus | Scripter | public | 2023-05-25 10:01 | 2023-05-28 23:43 |
Reporter | DavidMiller | Assigned To | jghali | ||
Priority | none | Severity | crash | Reproducibility | always |
Status | closed | Resolution | no change required | ||
Platform | Macintosh | OS | macOS | OS Version | 11.7.6 |
Summary | 0016947: Scribus text export script not working | ||||
Description | Hello, relative newbie to Scribus here with a problem exporting text from a file using the script here (https://wiki.scribus.net/canvas/Export_all_text). This is in Scribus 1.5.8. I copied and pasted the script into a text file (attached) and saved it to the Scribus scripts folder and I can see it in the Scripts menu. But when I try running it, it returns the following error. I'm no Python export so have no idea how to fix this or even if it can be fixed. I'd be grateful for any pointers on how to fix (apart from learning Python which I will get round to). Traceback (most recent call last): File "<string>", line 11, in <module> File "<string>", line 50 except Exception, e: # in case of syntax error, rather use : "except Exception as e :" ^ SyntaxError: invalid syntax | ||||
Additional Information | I wonder if this may have something to do with installing Scribus from a DMG file. Maybe some Python dependency isn't included by that particular method. Although some of the pre-installed scripts work, I get "This script will not work without tkinter Please install and try again" with FontSample, for example. | ||||
Tags | No tags attached. | ||||
Patch | No | ||||
|
text_out.py (1,982 bytes)
#!/usr/bin/env python # File: extract_text.py - Extracts the text from a document, saving to a text file # also lists image files with pathnames # 2006.03.04 Gregory Pittman # 2008.02.28 Petr Vanek - fileDialog replaces valueDialog # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. import scribus def exportText(textfile): page = 1 pagenum = scribus.pageCount() T = [] content = [] while (page <= pagenum): scribus.gotoPage(page) d = scribus.getPageItems() strpage = str(page) T.append('Page '+ strpage + '\n\n') for item in d: if (item[1] == 4): contents = scribus.getAllText(item[0]) if (contents in content): contents = 'Duplication, perhaps linked-to frame' T.append(item[0]+': '+ contents + '\n\n') content.append(contents) elif (item[1] == 2): imgname = scribus.getImageFile(item[0]) T.append(item[0]+': ' + imgname + '\n') page += 1 T.append('\n') output_file = open(textfile,'w') output_file.writelines(T) output_file.close() endmessage = textfile + ' was created' scribus.messageBox("Finished", endmessage,icon=0,button1=1) if scribus.haveDoc(): textfile = scribus.fileDialog('Enter name of file to save to', \ filter='Text Files (*.txt);;All Files (*)') try: if textfile == '': raise Exception exportText(textfile) except Exception, e: # in case of syntax error, rather use : "except Exception as e :" print e else: scribus.messageBox('Export Error', 'You need a Document open, and a frame selected.', \ icon=0, button1=1) |
|
The version of the script you have downlaoded is an old script for an unmaintained version of Scribus. This scripts requires Python 2, Scribus now uses Python 3. You have another version of the script updated for 1.5.x in the "Version of script as of 1.5.x series" section of same page. As following line mentions it, you may have to change the script depending on 1.5.x version and Python version you are using: except Exception, e: # in case of syntax error, rather use : "except Exception as e :" Afaik, Scribus 1.5.8 now also uses Python 3 on Mac OS. So you have to change this line to: except Exception as e : |
Date Modified | Username | Field | Change |
---|---|---|---|
2023-05-25 10:01 | DavidMiller | New Issue | |
2023-05-25 10:01 | DavidMiller | File Added: text_out.py | |
2023-05-28 23:24 | jghali | Project | Contributor Builds => Scribus |
2023-05-28 23:25 | jghali | Priority | high => none |
2023-05-28 23:25 | jghali | Category | General => - |
2023-05-28 23:25 | jghali | Category | - => Scripter |
2023-05-28 23:41 | jghali | Note Added: 0050193 | |
2023-05-28 23:42 | jghali | Note Edited: 0050193 | |
2023-05-28 23:43 | jghali | Assigned To | => jghali |
2023-05-28 23:43 | jghali | Status | new => resolved |
2023-05-28 23:43 | jghali | Resolution | open => no change required |
2023-05-28 23:43 | jghali | Status | resolved => closed |