diff options
Diffstat (limited to 'grc/base')
-rw-r--r-- | grc/base/Block.py | 58 | ||||
-rw-r--r-- | grc/base/Connection.py | 12 | ||||
-rw-r--r-- | grc/base/Element.py | 6 | ||||
-rw-r--r-- | grc/base/FlowGraph.py | 54 | ||||
-rw-r--r-- | grc/base/Param.py | 6 | ||||
-rw-r--r-- | grc/base/ParseXML.py | 16 | ||||
-rw-r--r-- | grc/base/Platform.py | 10 | ||||
-rw-r--r-- | grc/base/Port.py | 10 | ||||
-rw-r--r-- | grc/base/odict.py | 12 |
9 files changed, 92 insertions, 92 deletions
diff --git a/grc/base/Block.py b/grc/base/Block.py index 5a91810b7d..c440f00b6b 100644 --- a/grc/base/Block.py +++ b/grc/base/Block.py @@ -56,11 +56,11 @@ class Block(Element): def __init__(self, flow_graph, n): """ Make a new block from nested data. - + Args: flow: graph the parent element n: the nested odict - + Returns: block a new block """ @@ -177,7 +177,7 @@ class Block(Element): def back_ofthe_bus(self, portlist): portlist.sort(key=lambda a: a.get_type() == 'bus'); - def filter_bus_port(self, ports): + def filter_bus_port(self, ports): buslist = [i for i in ports if i.get_type() == 'bus']; if len(buslist) == 0: return ports; @@ -187,7 +187,7 @@ class Block(Element): def get_enabled(self): """ Get the enabled state of the block. - + Returns: true for enabled """ @@ -197,7 +197,7 @@ class Block(Element): def set_enabled(self, enabled): """ Set the enabled state of the block. - + Args: enabled: true for enabled """ @@ -225,11 +225,11 @@ class Block(Element): def get_param_keys(self): return _get_keys(self._params) def get_param(self, key): return _get_elem(self._params, key) def get_params(self): return self._params - def has_param(self, key): - try: - _get_elem(self._params, key); - return True; - except: + def has_param(self, key): + try: + _get_elem(self._params, key); + return True; + except: return False; ############################################## @@ -246,7 +246,7 @@ class Block(Element): def get_source_keys(self): return _get_keys(self._sources) def get_source(self, key): return _get_elem(self._sources, key) def get_sources(self): return self._sources - def get_sources_gui(self): return self.filter_bus_port(self.get_sources()); + def get_sources_gui(self): return self.filter_bus_port(self.get_sources()); def get_connections(self): return sum([port.get_connections() for port in self.get_ports()], []) @@ -254,10 +254,10 @@ class Block(Element): def resolve_dependencies(self, tmpl): """ Resolve a paramater dependency with cheetah templates. - + Args: tmpl: the string with dependencies - + Returns: the resolved value """ @@ -273,10 +273,10 @@ class Block(Element): def type_controller_modify(self, direction): """ Change the type controller. - + Args: direction: +1 or -1 - + Returns: true for change """ @@ -302,10 +302,10 @@ class Block(Element): def port_controller_modify(self, direction): """ Change the port controller. - + Args: direction: +1 or -1 - + Returns: true for change """ @@ -323,7 +323,7 @@ class Block(Element): struct = [range(len(get_p()))]; if True in map(lambda a: isinstance(a.get_nports(), int), get_p()): - + structlet = []; last = 0; @@ -332,7 +332,7 @@ class Block(Element): last = structlet[-1] + 1; struct = [structlet]; if bus_structure: - + struct = bus_structure self.current_bus_structure[direc] = struct; @@ -353,10 +353,10 @@ class Block(Element): for connect in elt.get_connections(): self.get_parent().remove_element(connect); - - - - + + + + if (not 'bus' in map(lambda a: a.get_type(), get_p())) and len(get_p()) > 0: @@ -364,16 +364,16 @@ class Block(Element): self.current_bus_structure[direc] = struct; if get_p()[0].get_nports(): n['nports'] = str(1); - + for i in range(len(struct)): n['key'] = str(len(get_p())); n = odict(n); port = self.get_parent().get_parent().Port(block=self, n=n, dir=direc); get_p().append(port); - - - + + + elif 'bus' in map(lambda a: a.get_type(), get_p()): for elt in get_p_gui(): get_p().remove(elt); @@ -384,7 +384,7 @@ class Block(Element): def export_data(self): """ Export this block's params to nested data. - + Returns: a nested data odict """ @@ -405,7 +405,7 @@ class Block(Element): call rewrite, and repeat the load until the params stick. This call to rewrite will also create any dynamic ports that are needed for the connections creation phase. - + Args: n: the nested data odict """ diff --git a/grc/base/Connection.py b/grc/base/Connection.py index 252b7deac1..b35ca91050 100644 --- a/grc/base/Connection.py +++ b/grc/base/Connection.py @@ -25,13 +25,13 @@ class Connection(Element): def __init__(self, flow_graph, porta, portb): """ Make a new connection given the parent and 2 ports. - + Args: flow_graph: the parent of this element porta: a port (any direction) portb: a port (any direction) @throws Error cannot make connection - + Returns: a new connection """ @@ -55,10 +55,10 @@ class Connection(Element): self._source = source self._sink = sink if source.get_type() == 'bus': - + sources = source.get_associated_ports(); sinks = sink.get_associated_ports(); - + for i in range(len(sources)): try: flow_graph.connect(sources[i], sinks[i]); @@ -89,7 +89,7 @@ class Connection(Element): def get_enabled(self): """ Get the enabled state of this connection. - + Returns: true if source and sink blocks are enabled """ @@ -108,7 +108,7 @@ class Connection(Element): def export_data(self): """ Export this connection's info. - + Returns: a nested data odict """ diff --git a/grc/base/Element.py b/grc/base/Element.py index be73ab264f..9c697b6393 100644 --- a/grc/base/Element.py +++ b/grc/base/Element.py @@ -36,7 +36,7 @@ class Element(object): def is_valid(self): """ Is this element valid? - + Returns: true when the element is enabled and has no error messages """ @@ -45,7 +45,7 @@ class Element(object): def add_error_message(self, msg): """ Add an error message to the list of errors. - + Args: msg: the error message string """ @@ -56,7 +56,7 @@ class Element(object): Get the list of error messages from this element and all of its children. Do not include the error messages from disabled children. Cleverly indent the children error messages for printing purposes. - + Returns: a list of error message strings """ diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py index 3c249ff71b..519d399aa8 100644 --- a/grc/base/FlowGraph.py +++ b/grc/base/FlowGraph.py @@ -26,10 +26,10 @@ class FlowGraph(Element): def __init__(self, platform): """ Make a flow graph from the arguments. - + Args: platform: a platforms with blocks and contrcutors - + Returns: the flow graph object """ @@ -41,10 +41,10 @@ class FlowGraph(Element): def _get_unique_id(self, base_id=''): """ Get a unique id starting with the base id. - + Args: base_id: the id starts with this and appends a count - + Returns: a unique id """ @@ -58,7 +58,7 @@ class FlowGraph(Element): def __str__(self): return 'FlowGraph - %s(%s)'%(self.get_option('title'), self.get_option('id')) def rewrite(self): def refactor_bus_structure(): - + for block in self.get_blocks(): for direc in ['source', 'sink']: if direc == 'source': @@ -69,11 +69,11 @@ class FlowGraph(Element): get_p = block.get_sinks; get_p_gui = block.get_sinks_gui bus_structure = block.form_bus_structure('sink'); - + if 'bus' in map(lambda a: a.get_type(), get_p_gui()): - - - + + + if len(get_p_gui()) > len(bus_structure): times = range(len(bus_structure), len(get_p_gui())); for i in times: @@ -84,17 +84,17 @@ class FlowGraph(Element): n = {'name':'bus','type':'bus'}; if True in map(lambda a: isinstance(a.get_nports(), int), get_p()): n['nports'] = str(1); - - times = range(len(get_p_gui()), len(bus_structure)); - + + times = range(len(get_p_gui()), len(bus_structure)); + for i in times: n['key'] = str(len(get_p())); n = odict(n); port = block.get_parent().get_parent().Port(block=block, n=n, dir=direc); get_p().append(port); - - - + + + for child in self.get_children(): child.rewrite() refactor_bus_structure(); @@ -102,10 +102,10 @@ class FlowGraph(Element): """ Get the option for a given key. The option comes from the special options block. - + Args: key: the param key for the options block - + Returns: the value held by that param """ @@ -132,7 +132,7 @@ class FlowGraph(Element): """ Get a list of all the elements. Always ensure that the options block is in the list (only once). - + Returns: the element list """ @@ -146,7 +146,7 @@ class FlowGraph(Element): def get_enabled_blocks(self): """ Get a list of all blocks that are enabled. - + Returns: a list of blocks """ @@ -155,7 +155,7 @@ class FlowGraph(Element): def get_enabled_connections(self): """ Get a list of all connections that are enabled. - + Returns: a list of connections """ @@ -165,10 +165,10 @@ class FlowGraph(Element): """ Get a new block of the specified key. Add the block to the list of elements. - + Args: key: the block key - + Returns: the new block or None if not found """ @@ -184,12 +184,12 @@ class FlowGraph(Element): def connect(self, porta, portb): """ Create a connection between porta and portb. - + Args: porta: a port portb: another port @throw Exception bad connection - + Returns: the new connection """ @@ -223,7 +223,7 @@ class FlowGraph(Element): def evaluate(self, expr): """ Evaluate the expression. - + Args: expr: the string expression @throw NotImplementedError @@ -237,7 +237,7 @@ class FlowGraph(Element): """ Export this flow graph to nested data. Export all block and connection data. - + Returns: a nested data odict """ @@ -253,7 +253,7 @@ class FlowGraph(Element): Import blocks and connections into this flow graph. Clear this flowgraph of all previous blocks and connections. Any blocks or connections in error will be ignored. - + Args: n: the nested data odict """ diff --git a/grc/base/Param.py b/grc/base/Param.py index 33ba7c3dbb..94be8b0fe0 100644 --- a/grc/base/Param.py +++ b/grc/base/Param.py @@ -63,7 +63,7 @@ class Param(Element): def __init__(self, block, n): """ Make a new param from nested data. - + Args: block: the parent element n: the nested odict @@ -162,7 +162,7 @@ class Param(Element): Get the repr (nice string format) for this param. Just return the value (special case enum). Derived classes can handle complex formatting. - + Returns: the string representation """ @@ -189,7 +189,7 @@ class Param(Element): def export_data(self): """ Export this param's key/value. - + Returns: a nested data odict """ diff --git a/grc/base/ParseXML.py b/grc/base/ParseXML.py index abb6576ac2..70af65192d 100644 --- a/grc/base/ParseXML.py +++ b/grc/base/ParseXML.py @@ -35,7 +35,7 @@ class XMLSyntaxError(Exception): def validate_dtd(xml_file, dtd_file=None): """ Validate an xml file against its dtd. - + Args: xml_file: the xml file dtd_file: the optional dtd file @@ -63,10 +63,10 @@ def validate_dtd(xml_file, dtd_file=None): def from_file(xml_file): """ Create nested data from an xml file using the from xml helper. - + Args: xml_file: the xml file path - + Returns: the nested data """ @@ -77,10 +77,10 @@ def from_file(xml_file): def _from_file(xml): """ Recursivly parse the xml tree into nested data format. - + Args: xml: the xml tree - + Returns: the nested data """ @@ -102,7 +102,7 @@ def _from_file(xml): def to_file(nested_data, xml_file): """ Write an xml file and use the to xml helper method to load it. - + Args: nested_data: the nested data xml_file: the xml file path @@ -114,10 +114,10 @@ def to_file(nested_data, xml_file): def _to_file(nested_data): """ Recursivly parse the nested data into xml tree format. - + Args: nested_data: the nested data - + Returns: the xml tree filled with child nodes """ diff --git a/grc/base/Platform.py b/grc/base/Platform.py index 187a50c01c..d322a16e83 100644 --- a/grc/base/Platform.py +++ b/grc/base/Platform.py @@ -35,7 +35,7 @@ class Platform(_Element): license='', website=None, colors=None): """ Make a platform from the arguments. - + Args: name: the platform name version: the version string @@ -47,7 +47,7 @@ class Platform(_Element): colors: a list of title, color_spec tuples license: a multi-line license (first line is copyright) website: the website url for this platform - + Returns: a platform object """ @@ -125,10 +125,10 @@ class Platform(_Element): """ Parse a saved flow graph file. Ensure that the file exists, and passes the dtd check. - + Args: flow_graph_file: the flow graph file - + Returns: nested data @throws exception if the validation fails @@ -143,7 +143,7 @@ class Platform(_Element): Load a block tree with categories and blocks. Step 1: Load all blocks from the xml specification. Step 2: Load blocks with builtin category specifications. - + Args: block_tree: the block tree object """ diff --git a/grc/base/Port.py b/grc/base/Port.py index b7de5301f1..edc309bf05 100644 --- a/grc/base/Port.py +++ b/grc/base/Port.py @@ -24,7 +24,7 @@ class Port(Element): def __init__(self, block, n, dir): """ Make a new port from nested data. - + Args: block: the parent element n: the nested odict @@ -66,7 +66,7 @@ class Port(Element): number = '' if self.get_type() == 'bus': busses = filter(lambda a: a._dir == self._dir, self.get_parent().get_ports_gui()); - + number = str(busses.index(self)) + '#' + str(len(self.get_associated_ports())); return self._name + number @@ -78,7 +78,7 @@ class Port(Element): def get_connections(self): """ Get all connections that use this port. - + Returns: a list of connection objects """ @@ -89,7 +89,7 @@ class Port(Element): def get_enabled_connections(self): """ Get all enabled connections that use this port. - + Returns: a list of connection objects """ @@ -107,7 +107,7 @@ class Port(Element): get_p = self.get_parent().get_sinks; bus_structure = self.get_parent().current_bus_structure['sink']; direc = 'sink' - + ports = [i for i in get_p() if not i.get_type() == 'bus']; if bus_structure: busses = [i for i in get_p() if i.get_type() == 'bus']; diff --git a/grc/base/odict.py b/grc/base/odict.py index 0c03d753f6..70ab67d053 100644 --- a/grc/base/odict.py +++ b/grc/base/odict.py @@ -50,7 +50,7 @@ class odict(DictMixin): """ Insert the new key, value entry after the entry given by the position key. If the positional key is None, insert at the end. - + Args: pos_key: the positional key key: the key for the new entry @@ -65,7 +65,7 @@ class odict(DictMixin): """ Insert the new key, value entry before the entry given by the position key. If the positional key is None, insert at the begining. - + Args: pos_key: the positional key key: the key for the new entry @@ -79,10 +79,10 @@ class odict(DictMixin): def find(self, key): """ Get the value for this key if exists. - + Args: key: the key to search for - + Returns: the value or None """ @@ -92,10 +92,10 @@ class odict(DictMixin): def findall(self, key): """ Get a list of values for this key. - + Args: key: the key to search for - + Returns: a list of values or empty list """ |