summaryrefslogtreecommitdiff
path: root/grc/python
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-07-07 12:20:09 -0400
committerTom Rondeau <tom@trondeau.com>2014-07-07 12:20:09 -0400
commitbbfc759914da80214fabc70fbbed1edaf39f9e4b (patch)
tree712eb6d1d95445bb6535534ce86d7faf1bfe6f90 /grc/python
parent3f469513b94ac992138360caca7e1b53f82214ae (diff)
parent597b93798a804cde1783d6d2ab53b348d57c44cd (diff)
Merge branch 'maint'
Diffstat (limited to 'grc/python')
-rw-r--r--grc/python/Block.py18
-rw-r--r--grc/python/FlowGraph.py50
-rw-r--r--grc/python/Generator.py2
-rw-r--r--grc/python/Param.py14
-rw-r--r--grc/python/Port.py8
-rw-r--r--grc/python/expr_utils.py24
-rw-r--r--grc/python/extract_docs.py8
7 files changed, 62 insertions, 62 deletions
diff --git a/grc/python/Block.py b/grc/python/Block.py
index 5dffcb3124..7a1c3a254f 100644
--- a/grc/python/Block.py
+++ b/grc/python/Block.py
@@ -34,11 +34,11 @@ class Block(_Block, _GUIBlock):
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
"""
@@ -65,14 +65,14 @@ class Block(_Block, _GUIBlock):
bus_structure = self._bus_structure_source;
else:
bus_structure = self._bus_structure_sink;
-
+
bus_structure = self.resolve_dependencies(bus_structure);
-
+
if not bus_structure: return ''
try:
clean_bus_structure = self.get_parent().evaluate(bus_structure)
return clean_bus_structure
-
+
except: return ''
def throttle(self): return bool(self._throttle)
@@ -124,10 +124,10 @@ class Block(_Block, _GUIBlock):
def port_controller_modify(self, direction):
"""
Change the port controller.
-
+
Args:
direction: +1 or -1
-
+
Returns:
true for change
"""
@@ -161,7 +161,7 @@ class Block(_Block, _GUIBlock):
Split each import statement at newlines.
Combine all import statments into a list.
Filter empty imports.
-
+
Returns:
a list of import statements
"""
@@ -173,7 +173,7 @@ class Block(_Block, _GUIBlock):
def get_callbacks(self):
"""
Get a list of function callbacks for this block.
-
+
Returns:
a list of strings
"""
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py
index 8573f33fc4..114f708cb2 100644
--- a/grc/python/FlowGraph.py
+++ b/grc/python/FlowGraph.py
@@ -41,12 +41,12 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
def _eval(self, code, namespace, namespace_hash):
"""
Evaluate the code with the given namespace.
-
+
Args:
code: a string with python code
namespace: a dict representing the namespace
namespace_hash: a unique hash for the namespace
-
+
Returns:
the resultant object
"""
@@ -61,10 +61,10 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
def get_io_signaturev(self, direction):
"""
Get a list of io signatures for this flow graph.
-
+
Args:
direction: a string of 'in' or 'out'
-
+
Returns:
a list of dicts with: type, label, vlen, size
"""
@@ -90,7 +90,7 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
def get_pad_sources(self):
"""
Get a list of pad source blocks sorted by id order.
-
+
Returns:
a list of pad source blocks in this flow graph
"""
@@ -100,7 +100,7 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
def get_pad_sinks(self):
"""
Get a list of pad sink blocks sorted by id order.
-
+
Returns:
a list of pad sink blocks in this flow graph
"""
@@ -135,7 +135,7 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
def get_imports(self):
"""
Get a set of all import statments in this flow graph namespace.
-
+
Returns:
a set of import statements
"""
@@ -147,7 +147,7 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
"""
Get a list of all variables in this flow graph namespace.
Exclude paramterized variables.
-
+
Returns:
a sorted list of variable blocks in order of dependency (indep -> dep)
"""
@@ -157,7 +157,7 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
def get_parameters(self):
"""
Get a list of all paramterized variables in this flow graph namespace.
-
+
Returns:
a list of paramterized variables
"""
@@ -174,15 +174,15 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
def get_bussink(self):
bussink = filter(lambda b: _bussink_searcher.search(b.get_key()), self.get_enabled_blocks())
-
+
for i in bussink:
for j in i.get_params():
if j.get_name() == 'On/Off' and j.get_value() == 'on':
return True;
-
+
return False
-
-
+
+
def get_bussrc(self):
bussrc = filter(lambda b: _bussrc_searcher.search(b.get_key()), self.get_enabled_blocks())
@@ -191,19 +191,19 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
for j in i.get_params():
if j.get_name() == 'On/Off' and j.get_value() == 'on':
return True;
-
+
return False
def get_bus_structure_sink(self):
bussink = filter(lambda b: _bus_struct_sink_searcher.search(b.get_key()), self.get_enabled_blocks())
-
+
return bussink
def get_bus_structure_src(self):
bussrc = filter(lambda b: _bus_struct_src_searcher.search(b.get_key()), self.get_enabled_blocks())
-
+
return bussrc
-
+
def rewrite(self):
"""
@@ -211,19 +211,19 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
"""
def reconnect_bus_blocks():
for block in self.get_blocks():
-
+
if 'bus' in map(lambda a: a.get_type(), block.get_sources_gui()):
-
-
+
+
for i in range(len(block.get_sources_gui())):
if len(block.get_sources_gui()[i].get_connections()) > 0:
source = block.get_sources_gui()[i]
sink = []
-
+
for j in range(len(source.get_connections())):
sink.append(source.get_connections()[j].get_sink());
-
-
+
+
for elt in source.get_connections():
self.remove_element(elt);
for j in sink:
@@ -235,11 +235,11 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
def evaluate(self, expr):
"""
Evaluate the expression.
-
+
Args:
expr: the string expression
@throw Exception bad expression
-
+
Returns:
the evaluated data
"""
diff --git a/grc/python/Generator.py b/grc/python/Generator.py
index 45958ba19b..eb24b75732 100644
--- a/grc/python/Generator.py
+++ b/grc/python/Generator.py
@@ -147,7 +147,7 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''')
'flow_graph': self._flow_graph,
'variables': variables,
'parameters': parameters,
- 'monitors': monitors,
+ 'monitors': monitors,
'blocks': blocks,
'connections': connections,
'messages': messages,
diff --git a/grc/python/Param.py b/grc/python/Param.py
index 3d9e52e25f..827355d8d6 100644
--- a/grc/python/Param.py
+++ b/grc/python/Param.py
@@ -66,7 +66,7 @@ class Param(_Param, _GUIParam):
def __repr__(self):
"""
Get the repr (nice string format) for this param.
-
+
Returns:
the string representation
"""
@@ -125,7 +125,7 @@ class Param(_Param, _GUIParam):
def get_color(self):
"""
Get the color that represents this param's type.
-
+
Returns:
a hex color code.
"""
@@ -160,7 +160,7 @@ class Param(_Param, _GUIParam):
If the parameter controls a port type, vlen, or nports, return part.
If the parameter is an empty grid position, return part.
These parameters are redundant to display in the flow graph view.
-
+
Returns:
hide the hide property string
"""
@@ -198,7 +198,7 @@ class Param(_Param, _GUIParam):
def evaluate(self):
"""
Evaluate the value.
-
+
Returns:
evaluated type
"""
@@ -407,7 +407,7 @@ class Param(_Param, _GUIParam):
Convert the value to code.
For string and list types, check the init flag, call evaluate().
This ensures that evaluate() was called to set the xxxify_flags.
-
+
Returns:
a string representing the code
"""
@@ -426,10 +426,10 @@ class Param(_Param, _GUIParam):
def get_all_params(self, type):
"""
Get all the params from the flowgraph that have the given type.
-
+
Args:
type: the specified type
-
+
Returns:
a list of params
"""
diff --git a/grc/python/Port.py b/grc/python/Port.py
index b82995cf6f..68e851f8c9 100644
--- a/grc/python/Port.py
+++ b/grc/python/Port.py
@@ -84,7 +84,7 @@ class Port(_Port, _GUIPort):
def __init__(self, block, n, dir):
"""
Make a new port from nested data.
-
+
Args:
block: the parent element
n: the nested odict
@@ -167,7 +167,7 @@ class Port(_Port, _GUIPort):
"""
Get the vector length.
If the evaluation of vlen cannot be cast to an integer, return 1.
-
+
Returns:
the vector length or 1
"""
@@ -180,7 +180,7 @@ class Port(_Port, _GUIPort):
Get the number of ports.
If already blank, return a blank
If the evaluation of nports cannot be cast to a positive integer, return 1.
-
+
Returns:
the number of ports or 1
"""
@@ -198,7 +198,7 @@ class Port(_Port, _GUIPort):
"""
Get the color that represents this port's type.
Codes differ for ports where the vec length is 1 or greater than 1.
-
+
Returns:
a hex color code.
"""
diff --git a/grc/python/expr_utils.py b/grc/python/expr_utils.py
index 85f420f04c..9e0b2a4a0a 100644
--- a/grc/python/expr_utils.py
+++ b/grc/python/expr_utils.py
@@ -54,10 +54,10 @@ def expr_split(expr):
Split up an expression by non alphanumeric characters, including underscore.
Leave strings in-tact.
#TODO ignore escaped quotes, use raw strings.
-
+
Args:
expr: an expression string
-
+
Returns:
a list of string tokens that form expr
"""
@@ -82,11 +82,11 @@ def expr_split(expr):
def expr_replace(expr, replace_dict):
"""
Search for vars in the expression and add the prepend.
-
+
Args:
expr: an expression string
replace_dict: a dict of find:replace
-
+
Returns:
a new expression with the prepend
"""
@@ -99,11 +99,11 @@ def expr_replace(expr, replace_dict):
def get_variable_dependencies(expr, vars):
"""
Return a set of variables used in this expression.
-
+
Args:
expr: an expression string
vars: a list of variable names
-
+
Returns:
a subset of vars used in the expression
"""
@@ -113,10 +113,10 @@ def get_variable_dependencies(expr, vars):
def get_graph(exprs):
"""
Get a graph representing the variable dependencies
-
+
Args:
exprs: a mapping of variable name to expression
-
+
Returns:
a graph of variable deps
"""
@@ -132,10 +132,10 @@ def get_graph(exprs):
def sort_variables(exprs):
"""
Get a list of variables in order of dependencies.
-
+
Args:
exprs: a mapping of variable name to expression
-
+
Returns:
a list of variable names
@throws Exception circular dependencies
@@ -156,12 +156,12 @@ def sort_variables(exprs):
def sort_objects(objects, get_id, get_expr):
"""
Sort a list of objects according to their expressions.
-
+
Args:
objects: the list of objects to sort
get_id: the function to extract an id from the object
get_expr: the function to extract an expression from the object
-
+
Returns:
a list of sorted objects
"""
diff --git a/grc/python/extract_docs.py b/grc/python/extract_docs.py
index b3b87e64ca..47b2820a1f 100644
--- a/grc/python/extract_docs.py
+++ b/grc/python/extract_docs.py
@@ -23,10 +23,10 @@ def _extract(key):
"""
Extract the documentation from the python __doc__ strings.
If multiple modules match, combine the docs.
-
+
Args:
key: the block key
-
+
Returns:
a string with documentation
"""
@@ -58,10 +58,10 @@ _docs_cache = dict()
def extract(key):
"""
Call the private extract and cache the result.
-
+
Args:
key: the block key
-
+
Returns:
a string with documentation
"""