From 1424d6b70c77728aee44d175c44ee6379388bca9 Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <koslowski@kit.edu> Date: Wed, 27 May 2015 09:08:15 +0200 Subject: grc: stop using gtk forall() (#793) --- grc/gui/PropsDialog.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'grc') diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index d301a75dd1..91f7f4ffe9 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -161,7 +161,9 @@ class PropsDialog(gtk.Dialog): for tab, label, vbox in self._params_boxes: vbox.hide_all() # empty the params box - vbox.forall(lambda c: vbox.remove(c) or c.destroy()) + for child in vbox.get_children(): + vbox.remove(child) + child.destroy() # repopulate the params box box_all_valid = True for param in filter(lambda p: p.get_tab_label() == tab, self._block.get_params()): @@ -202,7 +204,8 @@ class PropsDialog(gtk.Dialog): def _handle_response(self, widget, response): if response in (gtk.RESPONSE_APPLY, gtk.RESPONSE_ACCEPT): for tab, label, vbox in self._params_boxes: - vbox.forall(lambda c: c.apply_pending_changes()) + for child in vbox.get_children(): + child.apply_pending_changes() self.set_response_sensitive(gtk.RESPONSE_APPLY, False) return True return False -- cgit v1.2.3 From 99ea6c2879e0ebd6be833b2541d9d94fa701382a Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <koslowski@kit.edu> Date: Tue, 2 Jun 2015 11:49:47 +0200 Subject: grc: fix file load error when connections are not unique (#794) --- grc/base/Connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc') diff --git a/grc/base/Connection.py b/grc/base/Connection.py index 3a2de5b9a5..bf3c75277c 100644 --- a/grc/base/Connection.py +++ b/grc/base/Connection.py @@ -51,7 +51,7 @@ class Connection(Element): #ensure that this connection (source -> sink) is unique for connection in self.get_parent().get_connections(): if connection.get_source() is source and connection.get_sink() is sink: - raise Exception('This connection between source and sink is not unique.') + raise LookupError('This connection between source and sink is not unique.') self._source = source self._sink = sink if source.get_type() == 'bus': -- cgit v1.2.3 From f184ccf0efcd52d455f8af13aae3d8eeeeefbfaa Mon Sep 17 00:00:00 2001 From: Tim K <tpkuester@gmail.com> Date: Mon, 1 Jun 2015 15:31:04 -0400 Subject: grc: better Popen argument handling for CLI based apps "python -u ..." argument to "xterm -e" should be treated as all one argument --- grc/python/Generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc') diff --git a/grc/python/Generator.py b/grc/python/Generator.py index a3f9f10fc1..fc1dd56f50 100644 --- a/grc/python/Generator.py +++ b/grc/python/Generator.py @@ -129,7 +129,7 @@ class TopBlockGenerator(object): # when in no gui mode on linux, use a graphical terminal (looks nice) xterm_executable = find_executable(XTERM_EXECUTABLE) if self._generate_options == 'no_gui' and xterm_executable: - cmds = [xterm_executable, '-e'] + cmds + cmds = [xterm_executable, '-e'] + ' '.join(cmds) p = subprocess.Popen( args=cmds, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, -- cgit v1.2.3 From 6c34b527cb4e083b4806c1e34e5503639591f8b7 Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <koslowski@kit.edu> Date: Tue, 2 Jun 2015 16:13:36 +0200 Subject: grc: clean-up ParseXML --- grc/base/ParseXML.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'grc') diff --git a/grc/base/ParseXML.py b/grc/base/ParseXML.py index a2cede1c86..c9dbccf9a6 100644 --- a/grc/base/ParseXML.py +++ b/grc/base/ParseXML.py @@ -41,9 +41,9 @@ def validate_dtd(xml_file, dtd_file=None): dtd_file: the optional dtd file @throws Exception validation fails """ - #perform parsing, use dtd validation if dtd file is not specified + # perform parsing, use dtd validation if dtd file is not specified + parser = etree.XMLParser(dtd_validation=not dtd_file) try: - parser = etree.XMLParser(dtd_validation=not dtd_file) xml = etree.parse(xml_file, parser=parser) except etree.LxmlError: pass @@ -101,9 +101,10 @@ def _from_file(xml): key, value = _from_file(elem).items()[0] if nested_data.has_key(key): nested_data[key].append(value) else: nested_data[key] = [value] - #delistify if the length of values is 1 + # delistify if the length of values is 1 for key, values in nested_data.iteritems(): - if len(values) == 1: nested_data[key] = values[0] + if len(values) == 1: + nested_data[key] = values[0] return odict({tag: nested_data}) @@ -116,15 +117,16 @@ def to_file(nested_data, xml_file): nested_data: the nested data xml_file: the xml file path """ - # Create the processing instruction from the array xml_data = "" instructions = nested_data.pop('_instructions', None) - if instructions: + if instructions: # create the processing instruction from the array xml_data += etree.tostring(etree.ProcessingInstruction( - 'grc', ' '.join("{0}='{1}'".format(*item) for item in instructions.iteritems()) + 'grc', ' '.join( + "{0}='{1}'".format(*item) for item in instructions.iteritems()) ), xml_declaration=True, pretty_print=True) xml_data += etree.tostring(_to_file(nested_data)[0], pretty_print=True) - open(xml_file, 'w').write(xml_data) + with open(xml_file, 'w') as fp: + fp.write(xml_data) def _to_file(nested_data): @@ -139,12 +141,14 @@ def _to_file(nested_data): """ nodes = list() for key, values in nested_data.iteritems(): - #listify the values if not a list + # listify the values if not a list if not isinstance(values, (list, set, tuple)): values = [values] for value in values: node = etree.Element(key) - if isinstance(value, (str, unicode)): node.text = value - else: node.extend(_to_file(value)) + if isinstance(value, (str, unicode)): + node.text = value + else: + node.extend(_to_file(value)) nodes.append(node) return nodes -- cgit v1.2.3 From 42c892c92d13ba8803983db118f018e5d6b9f9b9 Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <koslowski@kit.edu> Date: Tue, 2 Jun 2015 16:14:31 +0200 Subject: grc: save grc files utf-8 encoded (#792) --- grc/base/ParseXML.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'grc') diff --git a/grc/base/ParseXML.py b/grc/base/ParseXML.py index c9dbccf9a6..2d5fed0862 100644 --- a/grc/base/ParseXML.py +++ b/grc/base/ParseXML.py @@ -123,8 +123,9 @@ def to_file(nested_data, xml_file): xml_data += etree.tostring(etree.ProcessingInstruction( 'grc', ' '.join( "{0}='{1}'".format(*item) for item in instructions.iteritems()) - ), xml_declaration=True, pretty_print=True) - xml_data += etree.tostring(_to_file(nested_data)[0], pretty_print=True) + ), xml_declaration=True, pretty_print=True, encoding='utf-8') + xml_data += etree.tostring(_to_file(nested_data)[0], + pretty_print=True, encoding='utf-8') with open(xml_file, 'w') as fp: fp.write(xml_data) @@ -147,7 +148,7 @@ def _to_file(nested_data): for value in values: node = etree.Element(key) if isinstance(value, (str, unicode)): - node.text = value + node.text = unicode(value) else: node.extend(_to_file(value)) nodes.append(node) -- cgit v1.2.3