42 Astoundingly Useful Scripts and Automations for the Macintosh
2019 August 23/6:00 AM
Work faster and more reliably. Add actions to the services menu and the menu bar, create drag-and-drop apps to make your Macintosh play music, roll dice, and talk. Create ASCII art from photos. There’s a script for that in 42 Astounding Scripts for the Macintosh.
Save all Scribus pages as EPS
Scribus is great at PDF, but Word isn’t. When I import PDFs into Word, Word converts them to bitmap graphics, which defeats the purpose of embedding PDF. Word does support EPS (as long as you’re printing to a postscript printer, such as CUPS-PDF), but Scribus can’t save pages separately to EPS files all at once like it can PDFs.
This script will go from page to page in the current Scribus document and save it as an EPS file.
[toggle code]
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import scribus
- import os.path
- #don't do anything unless there's a document open
-
if scribus.haveDoc():
- #get the base filename to save to
- #fileDialog seems to require three unnamed arguments
- saveTo = scribus.fileDialog('Select filename to save EPS files', '*.eps *.pdf *.sla', "", issave=True)
-
if saveTo:
- #deselect, or it will only print the current selection
- scribus.deselectAll()
- pagecount = scribus.pageCount()
- basePath, ext = os.path.splitext(saveTo)
-
if not ext:
- basePath = saveTo
-
for page in range(1, pagecount+1):
- scribus.gotoPage(page)
- filepath = basePath + ' page ' + str(page) + '.eps'
- scribus.savePageAsEPS(filepath)
-
else:
- scribus.messageBox("No Open Document", "You need to have a document open to save it as EPS.")
Save this script as something like “scribus2eps.py”, and then select it from your Scribus “Scripts” menu. Whatever filename you select, the script saves as that filename and “ page x.eps”. For example, if you choose "Joe.pdf", and the current document is three pages long, the pages will be saved as “Joe page 1.eps”, “Joe page 2.eps”, and “Joe page 3.eps”.
- CUPS-PDF
- CUPS-PDF lets you print straight to PDF if your system uses CUPS (as Mac OS X does). This lets you create PDFs using all of the print dialog’s printing options, such as more than one page per sheet.
- Scribus
- Scribus is a very nice open source page layout application and includes full PDF creation. It is also scriptable using Python if you need to automate page layout tasks. Scribus is very useful for making documents that need to be shared with other editors, since anyone can get the Scribus application unrestricted.
More Python
- Goodreads: What books did I read last week and last month?
- I occasionally want to look in Goodreads for what I read last month or last week, and that currently means sorting by date read and counting down to the beginning and end of the period in question. This Python script will do that search on an exported Goodreads csv file.
- Test classes and objects in python
- One of the advantages of object-oriented programming is that objects can masquerade as each other.
- Timeout class with retry in Python
- In Paramiko’s ssh client, timeouts don’t seem to work; a signal can handle this—and then can also perform a retry.
- Percentage-based random tables
- Our current random item generator assumes that each item shows up as often as any other item. That’s very OD&D-ish. But AD&D uses percentage dice to weight toward some monsters and items more than others.
- Parsing JSKit/Echo XML comments files
- While I’m not a big fan of remote comment systems for privacy reasons, I was willing to use JSKit as a temporary solution because they provide an easy XML dump of posted comments. This weekend, I finally moved my main blog to custom comments; here’s how I parsed JSKit’s XML file.
- 28 more pages with the topic Python, and other related pages
Update: issave=True doesn’t seem to have any effect in fileDialog. The button remains “open” instead of “save”, and the dialog requires choosing an existing file to determine the base name of the file. Just typing a new file name won’t cut it.