| www.delorie.com/archives/browse.cgi | search |
On Fri, 10 Jul 2015, gedau AT igor2 DOT repo DOT hu wrote:
> So next time I have something similar to solve, I will first ask you for the
> scheme code and only if that fails I do the dirty sch-parsing awk fewliner.
You could use Xorn. Since this uses the actual gEDA parsing code, the
result is exactly what gEDA would see when reading the file. Taking the
"outputting coords of line segments" task as an example, this would be:
import xorn.storage
from xorn.geda.read import read
sch = read('some-schematic.sch')
for ob in sch.toplevel_objects():
data = ob.data()
if isinstance(data, xorn.storage.Line):
print 'X1: %d Y1: %d X2: %d Y2: %d' % (
data.x, data.y, data.x + data.width, data.y + data.height)
You don't have to install Xorn in order import its modules; just add the
directory "built-packages" in the build directory to PYTHONPATH.
Roland
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |