Merge fixes from branch 'xorn'
[geda-gaf.git] / xorn / src / gaf / netlist / pp_power.py
blobf7904e05c4b685ed151c0df0135b1a025e0948a5
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 ## \namespace gaf.netlist.pp_power
21 ## Post-processing: New-style power symbols.
23 from gettext import gettext as _
24 import gaf.attrib
26 def postproc_blueprints(netlist):
27 for schematic in netlist.schematics:
28 for component in schematic.components:
29 netname = component.get_attribute('netname', None)
30 if netname is None:
31 continue
33 if component.refdes is not None:
34 component.error(_("refdes= and netname= attributes "
35 "are mutually exclusive"))
36 if gaf.attrib.search_all(component.ob, 'net'):
37 component.error(_("netname= and net= attributes "
38 "are mutually exclusive"))
40 if not component.pins:
41 component.error(_("power symbol doesn't have pins"))
42 if len(component.pins) > 1:
43 component.error(_("multiple pins on power symbol"))
45 for pin in component.pins:
46 if pin.number is not None or pin.ob.attached_objects():
47 pin.warn(_("pin attributes on power symbol are ignored"))
48 pin.net.names_from_net_attribute.append(netname)
50 component.has_netname_attrib = True