Xorn
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
pp_graphical.py
Go to the documentation of this file.
1 # xorn.geda.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-2016 Roland Lutz
5 #
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.
10 #
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.
15 #
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.
19 
20 ## \namespace xorn.geda.netlist.pp_graphical
21 ## Post-processing: Graphical components.
22 
23 from gettext import gettext as _
24 import xorn.geda.attrib
25 
26 def postproc_blueprints(netlist):
27  for schematic in netlist.schematics:
28  for component in schematic.components:
29  # gnetlist once checks for the existence of a "graphical="
30  # attribute and once checks whether the first value is 1,
31  # so if these tests give different results, gnetlist has
32  # an inconsistent internal state. -> warn about this
33  graphical_attribs = \
34  xorn.geda.attrib.search_all(component.ob, 'graphical')
35  if graphical_attribs and graphical_attribs[0] != '1':
36  component.error(_("invalid value for graphical= attribute"))
37 
38  component.is_graphical = \
39  component.get_attribute('graphical', None) == '1'
40 
41  if component.is_graphical and component.composite_sources:
42  # Do not bother traversing the hierarchy if the symbol
43  # has an graphical attribute attached to it.
44  component.warn(_("source= is set for graphical component"))
45  component.composite_sources = []
46 
47 def postproc_instances(netlist):
48  for net in netlist.nets:
49  net.graphical_component_pins = []
50 
51  remove_components = set()
52 
53  for component in netlist.components:
54  if not component.blueprint.is_graphical:
55  continue
56 
57  # remove component
58  remove_components.add(component)
59  component.sheet.components.remove(component)
60  del component.sheet.components_by_blueprint[component.blueprint]
61 
62  for cpin in component.cpins:
63  # remove cpin
64  cpin.local_net.cpins.remove(cpin)
65  cpin.local_net.net.component_pins.remove(cpin)
66 
67  # but add it to graphical_component_pins
68  cpin.local_net.net.graphical_component_pins.append(cpin)
69 
70  netlist.components = [component for component in netlist.components
71  if component not in remove_components]
Attribute parsing and lookup.
Definition: attrib.py:1
def search_all
Search both attached and inherited attributes of a component for an attribute name and return matchin...
Definition: attrib.py:186