X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:content-type; bh=qv+LB/HlnSmnHnZuml5QEmfMk4nFz608vJNAkF9NcRc=; b=XosRb7tzJUTxtLbFWLi0DRiXUIUs6Xwjz/gkgBiMjlNfkX1zm6v15r9wECaEYGhhtd 2oUG5gh56b3AukqgrefAkUk1BqeY6LXydFSLKn6LiLcGWCwUSGZQN1RqkKCl9cNWpa9w H0CjHJPuXo65sgIo6vgfnglaRxBdO3bZV2PqSLPcKsDpQidE6kzrqi9w/gIiYCuTdF0l Xu5xFpmYjv5xz5Sqxd2MZfc3Fx3zypmqkP/FSiEhg/fRmvzJq4FJRORDeTO9EbE2iZsq wjQ5DPLwxq9/gWq6a2/TqH9E3PdyPgieQjSfSuw9zvU5MMz3fIfs5Yuas9Xzw37QjApt WPYg== X-Gm-Message-State: ALoCoQktJy743a50Yr9i4iLpv1NFIocsXemoKZpvYRe0dHb10beR1uiBdR4CwnThHuQUv+98wZ+Y X-Received: by 10.152.121.42 with SMTP id lh10mr38022494lab.0.1436875075843; Tue, 14 Jul 2015 04:57:55 -0700 (PDT) MIME-Version: 1.0 Sender: mjd AT hackvana DOT com X-Originating-IP: [120.21.197.173] In-Reply-To: References: <559E86A4 DOT 3040109 AT ecosensory 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> <20150710132650 DOT GA15876 AT localhost DOT localdomain> <20150710152308 DOT GA17023 AT localhost DOT localdomain> From: "Mitch Davis (mjd+geda-user AT hackvana DOT com) [via geda-user AT delorie DOT com]" Date: Tue, 14 Jul 2015 21:57:36 +1000 X-Google-Sender-Auth: 7HJdvB-xm3Z4PKkfCsbRwfYEHBs Message-ID: Subject: Re: [geda-user] why I parse sch: gnetlist, writing backends (Back annotation) To: geda-user AT delorie DOT com Content-Type: multipart/alternative; boundary=089e011774857b8d5a051ad48c74 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 Precedence: bulk --089e011774857b8d5a051ad48c74 Content-Type: text/plain; charset=UTF-8 On Sat, Jul 11, 2015 at 7:34 AM, Roland Lutz wrote: > 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) > I don't know why everyone is complaining about Scheme. I can read this just fine, the first time I ever saw it. M. --089e011774857b8d5a051ad48c74 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Sat, Jul 11, 2015 at 7:34 AM, Roland Lutz <rl= utz AT hedmen DOT org> wrote:
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 th= e scheme code and only if that fails I do the dirty sch-parsing awk fewline= r.

You could use Xorn.=C2=A0 Since this uses the actual gEDA parsing code, the= result is exactly what gEDA would see when reading the file.=C2=A0 Taking = the "outputting coords of line segments" task as an example, this= would be:

=C2=A0 =C2=A0 import xorn.storage
=C2=A0 =C2=A0 from xorn.geda.read import read

=C2=A0 =C2=A0 sch =3D read('some-schematic.sch')

=C2=A0 =C2=A0 for ob in sch.toplevel_objects():
=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D ob.data()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if isinstance(data, xorn.storage.Line):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print 'X1: %d Y1: %d X2: %d Y= 2: %d' % (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 data.x, data.y, dat= a.x + data.width, data.y + data.height)

I don'= t know why everyone is complaining about Scheme.=C2=A0 I can read this just= fine, the first time I ever saw it.

M.
--089e011774857b8d5a051ad48c74--