summaryrefslogtreecommitdiff
path: root/grc/python/Port.py
diff options
context:
space:
mode:
authorJosh Blum2011-04-14 10:05:33 -0700
committerJosh Blum2011-04-14 10:05:33 -0700
commit4cdd41c1046cef12601602bd38dc8ebf42d1550d (patch)
treeec1fb606bfaa6ffe79d677c3bd4a5fa64c18f7bf /grc/python/Port.py
parent8fb43aa9093fbbb5c9d8b9418c144dbf33730127 (diff)
downloadgnuradio-4cdd41c1046cef12601602bd38dc8ebf42d1550d.tar.gz
gnuradio-4cdd41c1046cef12601602bd38dc8ebf42d1550d.tar.bz2
gnuradio-4cdd41c1046cef12601602bd38dc8ebf42d1550d.zip
grc: replaced asserts in python subdirectory
Diffstat (limited to 'grc/python/Port.py')
-rw-r--r--grc/python/Port.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/grc/python/Port.py b/grc/python/Port.py
index 6e5a5c59f..3846b0f4e 100644
--- a/grc/python/Port.py
+++ b/grc/python/Port.py
@@ -1,5 +1,5 @@
"""
-Copyright 2008, 2009 Free Software Foundation, Inc.
+Copyright 2008-2011 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
@@ -83,16 +83,16 @@ class Port(_Port, _GUIPort):
def validate(self):
_Port.validate(self)
- try: assert self.get_enabled_connections() or self.get_optional()
- except AssertionError: self.add_error_message('Port is not connected.')
- try: assert self.is_source() or len(self.get_enabled_connections()) <= 1
- except AssertionError: self.add_error_message('Port has too many connections.')
+ if not self.get_enabled_connections() and not self.get_optional():
+ self.add_error_message('Port is not connected.')
+ if not self.is_source() and len(self.get_enabled_connections()) > 1:
+ self.add_error_message('Port has too many connections.')
#message port logic
if self.get_type() == 'msg':
- try: assert not self.get_nports()
- except AssertionError: self.add_error_message('A port of type "msg" cannot have "nports" set.')
- try: assert self.get_vlen() == 1
- except AssertionError: self.add_error_message('A port of type "msg" must have a "vlen" of 1.')
+ if self.get_nports():
+ self.add_error_message('A port of type "msg" cannot have "nports" set.')
+ if self.get_vlen() != 1:
+ self.add_error_message('A port of type "msg" must have a "vlen" of 1.')
def rewrite(self):
"""
@@ -134,8 +134,7 @@ class Port(_Port, _GUIPort):
if not nports: return ''
try:
nports = int(self.get_parent().get_parent().evaluate(nports))
- assert 0 < nports
- return nports
+ if 0 < nports: return nports
except: return 1
def get_optional(self): return bool(self._optional)