Visions of Aestia

29 Mar 2006

Gtk/Print - hope at last!

Filed under: General — JBowtie @ 11:13 pm

I’ve been disappointed for a long time in how broken printing was using PyGTK; currently I just dump out a PDF in a temp file and send that to the printer.

Luckily, the (poorly-documented and little used) GnomePrint and GnomePrintUI are on the way out, and a cairo-based printing API with cross-platform support has been merged into GTK. The API looks stellar, J5 claims it will be documented, and my salvation is at hand.

Neat Python trick

Filed under: Python — JBowtie @ 10:46 pm

This is mostly as a reminder to myself, in case I forget again.

If you want to put all your unit tests in a subdirectory called “tests”, do so and add “..” to the python path.

import sys, os, re, unittest, os.path
        
def regressionTest():
        path=os.path.abspath(os.path.dirname(sys.argv[0]))
        files=os.listdir(path)
        test=re.compile(\"tests.py$\", re.IGNORECASE)
        files=filter(test.search, files)
        filenameToModuleName = lambda f: os.path.splitext(f)[0]
        moduleNames=map(filenameToModuleName, files)
        modules = map(__import__, moduleNames)
        load = unittest.defaultTestLoader.loadTestsFromModule
        return unittest.TestSuite(map(load,modules))
        
if __name__ == \"__main__\":
        sys.path.append(os.path.abspath(\"..\"))
        unittest.main(defaultTest=\"regressionTest\")

Now I am happy.

Powered by WordPress