www.delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2015/07/10/17:35:51

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
Date: Fri, 10 Jul 2015 23:34:22 +0200 (CEST)
From: Roland Lutz <rlutz AT hedmen DOT org>
To: "Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com>
Subject: Re: [geda-user] why I parse sch: gnetlist, writing backends (Back
annotation)
In-Reply-To: <alpine.DEB.2.00.1507101813250.6924@igor2priv>
Message-ID: <alpine.DEB.2.11.1507102316100.2863@nimbus>
References: <559E86A4 DOT 3040109 AT ecosensory DOT com> <DC183265-AD4B-4707-970F-1EE5D3578126 AT noqsi DOT com> <201507091843 DOT t69IhGF6028321 AT envy DOT delorie DOT com> <6392CE1A-AFA0-4D62-979C-3F35786422BD AT noqsi DOT com> <201507092127 DOT t69LRHRC001744 AT envy DOT delorie DOT com> <559EFE69 DOT 1040601 AT zoot DOT drehmel DOT com>
<201507092332 DOT t69NWUEN006109 AT envy DOT delorie DOT com> <alpine DOT DEB DOT 2 DOT 00 DOT 1507100501200 DOT 6924 AT igor2priv> <20150710132650 DOT GA15876 AT localhost DOT localdomain> <alpine DOT DEB DOT 2 DOT 00 DOT 1507101547500 DOT 6924 AT igor2priv> <20150710152308 DOT GA17023 AT localhost DOT localdomain>
<alpine DOT DEB DOT 2 DOT 00 DOT 1507101813250 DOT 6924 AT igor2priv>
User-Agent: Alpine 2.11 (DEB 23 2013-08-11)
MIME-Version: 1.0
Reply-To: geda-user AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: geda-user AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019