missing NULL terminator in set_config_x
[geda-gaf.git] / xorn / src / backend / gnet_pcbpins.py
blob42d675a0c4d6b7970b6f66157eeed93661d81ef7
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 # Backend for propagating pin names from gschem to footprints in pcb
21 # Copyright (C) 2005-2010 Dan McMahill
23 # A comma or close parenthesis will cause problems with the pcb action
24 # script, so if one of the arguments to ChangePinName contains one it
25 # should be quoted. Any quote characters within the argument are
26 # escaped.
28 # At present, this function only quotes if there is a comma or close
29 # parenthesis present in the string.
31 def quote_string(s):
32 if ',' not in s and ')' not in s:
33 return s
34 return '"' + s.replace('"', '\"') + '"'
36 def run(f, netlist):
37 f.write('# Pin name action command file\n')
38 for package in reversed(netlist.packages):
39 f.write('\n')
40 f.write('# Start of element %s\n' % package.refdes)
41 for pin in reversed(package.pins):
42 pinnum = pin.get_attribute('pinnumber', 'unknown')
43 label = pin.get_attribute('pinlabel', pinnum)
44 f.write('ChangePinName(%s, %s, %s)\n' % (
45 quote_string(package.refdes),
46 quote_string(pinnum),
47 quote_string(label)))