Merge r6461:6464 from jcorgan/t162-staging into trunk.
[debian/gnuradio] / gnuradio-core / src / python / gnuradio / gr / hier_block2.py
index bc6402b8726ef2a0efaa941b095e528940246e8c..1c096b709e0385041e507bd59c5f140a62ae7f6c 100644 (file)
@@ -37,13 +37,17 @@ class hier_block2(object):
        return getattr(self._hb, name)
 
     def connect(self, *points):
-        '''connect requires two or more arguments that can be coerced to endpoints.
+        '''connect requires one or more arguments that can be coerced to endpoints.
         If more than two arguments are provided, they are connected together successively.
         '''
-        if len (points) < 2:
-            raise ValueError, ("connect requires at least two endpoints; %d provided." % (len (points),))
-        for i in range (1, len (points)):
-            self._connect(points[i-1], points[i])
+        if len (points) < 1:
+            raise ValueError, ("connect requires at least one endpoint; %d provided." % (len (points),))
+       else:
+           if len(points) == 1:
+               self._hb.connect(points[0].basic_block())
+           else:
+               for i in range (1, len (points)):
+                   self._connect(points[i-1], points[i])
 
     def _connect(self, src, dst):
         (src_block, src_port) = self._coerce_endpoint(src)
@@ -61,13 +65,17 @@ class hier_block2(object):
                 raise ValueError("unable to coerce endpoint")
 
     def disconnect(self, *points):
-        '''connect requires two or more arguments that can be coerced to endpoints.
+        '''connect requires one or more arguments that can be coerced to endpoints.
         If more than two arguments are provided, they are disconnected successively.
         '''
-        if len (points) < 2:
+        if len (points) < 1:
             raise ValueError, ("disconnect requires at least two endpoints; %d provided." % (len (points),))
-        for i in range (1, len (points)):
-            self._disconnect(points[i-1], points[i])
+        else:
+            if len (points) == 1:
+                self._hb.disconnect(points[0].basic_block())
+            else:
+                for i in range (1, len (points)):
+                    self._disconnect(points[i-1], points[i])
 
     def _disconnect(self, src, dst):
         (src_block, src_port) = self._coerce_endpoint(src)