summaryrefslogtreecommitdiff
path: root/grc/core
diff options
context:
space:
mode:
Diffstat (limited to 'grc/core')
-rw-r--r--grc/core/Block.py8
-rw-r--r--grc/core/Element.py11
-rw-r--r--grc/core/FlowGraph.py2
-rw-r--r--grc/core/Param.py6
-rw-r--r--grc/core/ParseXML.py1
-rw-r--r--grc/core/Port.py2
-rw-r--r--grc/core/generator/flow_graph.tmpl9
7 files changed, 24 insertions, 15 deletions
diff --git a/grc/core/Block.py b/grc/core/Block.py
index c2c7d4e821..6708986939 100644
--- a/grc/core/Block.py
+++ b/grc/core/Block.py
@@ -21,7 +21,6 @@ import collections
import itertools
from Cheetah.Template import Template
-from UserDict import UserDict
from .utils import epy_block_io, odict
from . Constants import (
@@ -442,11 +441,10 @@ class Block(Element):
self._params.remove(param)
for key, value in blk_io.params:
- if key in params:
+ try:
param = params[key]
- if not param.value_is_default():
- param.set_value(value)
- else:
+ param.set_default(value)
+ except KeyError: # need to make a new param
name = key.replace('_', ' ').title()
n = odict(dict(name=name, key=key, type='raw', value=value))
param = platform.Param(block=self, n=n)
diff --git a/grc/core/Element.py b/grc/core/Element.py
index c999d6704f..b96edb0a72 100644
--- a/grc/core/Element.py
+++ b/grc/core/Element.py
@@ -41,9 +41,9 @@ class Element(object):
Is this element valid?
Returns:
- true when the element is enabled and has no error messages
+ true when the element is enabled and has no error messages or is bypassed
"""
- return not self.get_error_messages() or not self.get_enabled()
+ return (not self.get_error_messages() or not self.get_enabled()) or self.get_bypassed()
def add_error_message(self, msg):
"""
@@ -57,14 +57,14 @@ class Element(object):
def get_error_messages(self):
"""
Get the list of error messages from this element and all of its children.
- Do not include the error messages from disabled children.
+ Do not include the error messages from disabled or bypassed children.
Cleverly indent the children error messages for printing purposes.
Returns:
a list of error message strings
"""
error_messages = list(self._error_messages) # Make a copy
- for child in filter(lambda c: c.get_enabled(), self.get_children()):
+ for child in filter(lambda c: c.get_enabled() and not c.get_bypassed(), self.get_children()):
for msg in child.get_error_messages():
error_messages.append("{}:\n\t{}".format(child, msg.replace("\n", "\n\t")))
return error_messages
@@ -80,6 +80,9 @@ class Element(object):
def get_enabled(self):
return True
+ def get_bypassed(self):
+ return False
+
##############################################
# Tree-like API
##############################################
diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py
index 177d16baa9..313af3107a 100644
--- a/grc/core/FlowGraph.py
+++ b/grc/core/FlowGraph.py
@@ -424,7 +424,7 @@ class FlowGraph(Element):
block.import_data(block_n)
- self.rewrite()
+ self.rewrite() # evaluate stuff like nports before adding connections
# build the connections
def verify_and_get_port(key, block, dir):
diff --git a/grc/core/Param.py b/grc/core/Param.py
index 04c4967f53..d155800c43 100644
--- a/grc/core/Param.py
+++ b/grc/core/Param.py
@@ -683,8 +683,10 @@ class Param(Element):
# Must be a string
self._value = str(value)
- def value_is_default(self):
- return self._default == self._value
+ def set_default(self, value):
+ if self._default == self._value:
+ self.set_value(value)
+ self._default = str(value)
def get_type(self):
return self.get_parent().resolve_dependencies(self._type)
diff --git a/grc/core/ParseXML.py b/grc/core/ParseXML.py
index 987fa2a13d..c9f6541ee7 100644
--- a/grc/core/ParseXML.py
+++ b/grc/core/ParseXML.py
@@ -22,6 +22,7 @@ from lxml import etree
from .utils import odict
xml_failures = {}
+etree.set_default_parser(etree.XMLParser(remove_comments=True))
class XMLSyntaxError(Exception):
diff --git a/grc/core/Port.py b/grc/core/Port.py
index 4964a94c2b..6a8f484082 100644
--- a/grc/core/Port.py
+++ b/grc/core/Port.py
@@ -129,7 +129,7 @@ class Port(Element):
# Grab the data
self._name = n['name']
self._key = n['key']
- self._type = n['type']
+ self._type = n['type'] or ''
self._domain = n['domain']
self._hide = n.find('hide') or ''
self._dir = dir
diff --git a/grc/core/generator/flow_graph.tmpl b/grc/core/generator/flow_graph.tmpl
index bd8025b676..ecdb89390e 100644
--- a/grc/core/generator/flow_graph.tmpl
+++ b/grc/core/generator/flow_graph.tmpl
@@ -274,8 +274,8 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
self.settings = Qt.QSettings("GNU Radio", "$class_name")
self.settings.setValue("geometry", self.saveGeometry())
event.accept()
-
#if $flow_graph.get_option('qt_qss_theme')
+
def setStyleSheetFromFile(self, filename):
try:
if not os.path.exists(filename):
@@ -336,7 +336,12 @@ $short_id#slurp
def argument_parser():
- parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
+ #set $desc_args = 'usage="%prog: [options]", option_class=eng_option'
+ #if $flow_graph.get_option('description')
+ #set $desc_args += ', description=description'
+ description = $repr($flow_graph.get_option('description'))
+ #end if
+ parser = OptionParser($desc_args)
#for $param in $parameters
#set $type = $param.get_param('type').get_value()
#if $type