Imported Upstream version 3.2.2
[debian/gnuradio] / grc / python / Connection.py
1 """
2 Copyright 2008 Free Software Foundation, Inc.
3 This file is part of GNU Radio
4
5 GNU Radio Companion is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 GNU Radio Companion is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18 """
19
20 from .. base.Connection import Connection as _Connection
21
22 class Connection(_Connection):
23
24         def validate(self):
25                 """
26                 Validate the connections.
27                 The ports must match in type and vector length.
28                 """
29                 _Connection.validate(self) #checks type
30                 #check vector length
31                 source_vlen = self.get_source().get_vlen()
32                 sink_vlen = self.get_sink().get_vlen()
33                 try: assert source_vlen == sink_vlen
34                 except AssertionError: self.add_error_message('Source vector length "%s" does not match sink vector length "%s".'%(source_vlen, sink_vlen))