Merge fixes from branch 'xorn'
[geda-gaf.git] / xorn / src / backend / gnet_geda.py
blobfb146df6a64706c9962c6ca08831cec06d2d3d67
1 # gaf.netlist - gEDA Netlist Extraction and Generation
2 # Copyright (C) 1998-2010 Ales Hvezda
3 # Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
4 # Copyright (C) 2013-2020 Roland Lutz
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # gEDA's native test netlist format
22 def run(f, netlist):
23 f.write('START header\n')
24 f.write('\n')
25 f.write('gEDA\'s netlist format\n')
26 f.write('Created specifically for testing of gnetlist\n')
27 f.write('\n')
28 f.write('END header\n')
29 f.write('\n')
31 f.write('START components\n')
32 f.write('\n')
34 for package in reversed(netlist.packages):
35 f.write('%s device=%s\n' % (
36 package.refdes,
37 package.get_attribute('device', 'unknown')))
39 f.write('\n')
40 f.write('END components\n')
41 f.write('\n')
43 f.write('START nets\n')
44 f.write('\n')
46 for net in reversed(netlist.nets):
47 # "netname : uref pin, uref pin, ..."
48 # Display the individual net connections
49 f.write('%s : %s \n' % (
50 net.name,
51 ', '.join('%s %s' % (pin.package.refdes, pin.number)
52 for pin in reversed(net.connections))))
54 f.write('\n')
55 f.write('END nets\n')
56 f.write('\n')