diff options
38 files changed, 816 insertions, 322 deletions
diff --git a/grc/base/Block.py b/grc/base/Block.py index fe7ad3c2f3..3c61bc90e3 100644 --- a/grc/base/Block.py +++ b/grc/base/Block.py @@ -54,9 +54,13 @@ class Block(Element): def __init__(self, flow_graph, n): """ Make a new block from nested data. - @param flow graph the parent element - @param n the nested odict - @return block a new block + + Args: + flow: graph the parent element + n: the nested odict + + Returns: + block a new block """ #build the block Element.__init__(self, flow_graph) @@ -118,7 +122,9 @@ class Block(Element): def get_enabled(self): """ Get the enabled state of the block. - @return true for enabled + + Returns: + true for enabled """ try: return eval(self.get_param('_enabled').get_value()) except: return True @@ -126,7 +132,9 @@ class Block(Element): def set_enabled(self, enabled): """ Set the enabled state of the block. - @param enabled true for enabled + + Args: + enabled: true for enabled """ self.get_param('_enabled').set_value(str(enabled)) @@ -169,8 +177,12 @@ class Block(Element): def resolve_dependencies(self, tmpl): """ Resolve a paramater dependency with cheetah templates. - @param tmpl the string with dependencies - @return the resolved value + + Args: + tmpl: the string with dependencies + + Returns: + the resolved value """ tmpl = str(tmpl) if '$' not in tmpl: return tmpl @@ -184,8 +196,12 @@ class Block(Element): def type_controller_modify(self, direction): """ Change the type controller. - @param direction +1 or -1 - @return true for change + + Args: + direction: +1 or -1 + + Returns: + true for change """ changed = False type_param = None @@ -209,8 +225,12 @@ class Block(Element): def port_controller_modify(self, direction): """ Change the port controller. - @param direction +1 or -1 - @return true for change + + Args: + direction: +1 or -1 + + Returns: + true for change """ return False @@ -220,7 +240,9 @@ class Block(Element): def export_data(self): """ Export this block's params to nested data. - @return a nested data odict + + Returns: + a nested data odict """ n = odict() n['key'] = self.get_key() @@ -235,7 +257,9 @@ 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. - @param n the nested data odict + + Args: + n: the nested data odict """ get_hash = lambda: hash(tuple(map(hash, self.get_params()))) my_hash = 0 diff --git a/grc/base/Connection.py b/grc/base/Connection.py index 3ce7fd07f9..b9afe1434d 100644 --- a/grc/base/Connection.py +++ b/grc/base/Connection.py @@ -25,11 +25,15 @@ class Connection(Element): def __init__(self, flow_graph, porta, portb): """ Make a new connection given the parent and 2 ports. - @param flow_graph the parent of this element - @param porta a port (any direction) - @param portb a port (any direction) + + Args: + flow_graph: the parent of this element + porta: a port (any direction) + portb: a port (any direction) @throws Error cannot make connection - @return a new connection + + Returns: + a new connection """ Element.__init__(self, flow_graph) source = sink = None @@ -70,7 +74,9 @@ class Connection(Element): def get_enabled(self): """ Get the enabled state of this connection. - @return true if source and sink blocks are enabled + + Returns: + true if source and sink blocks are enabled """ return self.get_source().get_parent().get_enabled() and \ self.get_sink().get_parent().get_enabled() @@ -87,7 +93,9 @@ class Connection(Element): def export_data(self): """ Export this connection's info. - @return a nested data odict + + Returns: + a nested data odict """ n = odict() n['source_block_id'] = self.get_source().get_parent().get_id() diff --git a/grc/base/Element.py b/grc/base/Element.py index a57090f3b2..74097eea9a 100644 --- a/grc/base/Element.py +++ b/grc/base/Element.py @@ -36,14 +36,18 @@ class Element(object): def is_valid(self): """ Is this element valid? - @return true when the element is enabled and has no error messages + + Returns: + true when the element is enabled and has no error messages """ return not self.get_error_messages() or not self.get_enabled() def add_error_message(self, msg): """ Add an error message to the list of errors. - @param msg the error message string + + Args: + msg: the error message string """ self._error_messages.append(msg) @@ -52,7 +56,9 @@ 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. - @return a list of error message strings + + 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()): diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py index 0ba1f23899..e8c49466d0 100644 --- a/grc/base/FlowGraph.py +++ b/grc/base/FlowGraph.py @@ -26,8 +26,12 @@ class FlowGraph(Element): def __init__(self, platform): """ Make a flow graph from the arguments. - @param platform a platforms with blocks and contrcutors - @return the flow graph object + + Args: + platform: a platforms with blocks and contrcutors + + Returns: + the flow graph object """ #initialize Element.__init__(self, platform) @@ -37,8 +41,12 @@ class FlowGraph(Element): def _get_unique_id(self, base_id=''): """ Get a unique id starting with the base id. - @param base_id the id starts with this and appends a count - @return a unique id + + Args: + base_id: the id starts with this and appends a count + + Returns: + a unique id """ index = 0 while True: @@ -53,8 +61,12 @@ class FlowGraph(Element): """ Get the option for a given key. The option comes from the special options block. - @param key the param key for the options block - @return the value held by that param + + Args: + key: the param key for the options block + + Returns: + the value held by that param """ return self._options_block.get_param(key).get_evaluated() @@ -71,7 +83,9 @@ class FlowGraph(Element): """ Get a list of all the elements. Always ensure that the options block is in the list (only once). - @return the element list + + Returns: + the element list """ options_block_count = self._elements.count(self._options_block) if not options_block_count: @@ -83,14 +97,18 @@ class FlowGraph(Element): def get_enabled_blocks(self): """ Get a list of all blocks that are enabled. - @return a list of blocks + + Returns: + a list of blocks """ return filter(lambda b: b.get_enabled(), self.get_blocks()) def get_enabled_connections(self): """ Get a list of all connections that are enabled. - @return a list of connections + + Returns: + a list of connections """ return filter(lambda c: c.get_enabled(), self.get_connections()) @@ -98,8 +116,12 @@ class FlowGraph(Element): """ Get a new block of the specified key. Add the block to the list of elements. - @param key the block key - @return the new block or None if not found + + Args: + key: the block key + + Returns: + the new block or None if not found """ if key not in self.get_parent().get_block_keys(): return None block = self.get_parent().get_new_block(self, key) @@ -109,10 +131,14 @@ class FlowGraph(Element): def connect(self, porta, portb): """ Create a connection between porta and portb. - @param porta a port - @param portb another port + + Args: + porta: a port + portb: another port @throw Exception bad connection - @return the new connection + + Returns: + the new connection """ connection = self.get_parent().Connection(flow_graph=self, porta=porta, portb=portb) self.get_elements().append(connection) @@ -138,7 +164,9 @@ class FlowGraph(Element): def evaluate(self, expr): """ Evaluate the expression. - @param expr the string expression + + Args: + expr: the string expression @throw NotImplementedError """ raise NotImplementedError @@ -150,7 +178,9 @@ class FlowGraph(Element): """ Export this flow graph to nested data. Export all block and connection data. - @return a nested data odict + + Returns: + a nested data odict """ import time n = odict() @@ -164,7 +194,9 @@ 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. - @param n the nested data odict + + Args: + n: the nested data odict """ #remove previous elements self._elements = list() diff --git a/grc/base/Param.py b/grc/base/Param.py index c2fa5461ae..76a74d3ed7 100644 --- a/grc/base/Param.py +++ b/grc/base/Param.py @@ -63,8 +63,10 @@ class Param(Element): def __init__(self, block, n): """ Make a new param from nested data. - @param block the parent element - @param n the nested odict + + Args: + block: the parent element + n: the nested odict """ #grab the data self._name = n.find('name') @@ -148,7 +150,9 @@ 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. - @return the string representation + + Returns: + the string representation """ if self.is_enum(): return self.get_option(self.get_value()).get_name() return self.get_value() @@ -173,7 +177,9 @@ class Param(Element): def export_data(self): """ Export this param's key/value. - @return a nested data odict + + Returns: + a nested data odict """ n = odict() n['key'] = self.get_key() diff --git a/grc/base/ParseXML.py b/grc/base/ParseXML.py index 078ebd078b..0d19f6b212 100644 --- a/grc/base/ParseXML.py +++ b/grc/base/ParseXML.py @@ -29,8 +29,10 @@ class XMLSyntaxError(Exception): def validate_dtd(xml_file, dtd_file=None): """ Validate an xml file against its dtd. - @param xml_file the xml file - @param dtd_file the optional dtd file + + Args: + xml_file: the xml file + dtd_file: the optional dtd file @throws Exception validation fails """ #perform parsing, use dtd validation if dtd file is not specified @@ -45,8 +47,12 @@ 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. - @param xml_file the xml file path - @return the nested data + + Args: + xml_file: the xml file path + + Returns: + the nested data """ xml = etree.parse(xml_file).getroot() return _from_file(xml) @@ -54,8 +60,12 @@ def from_file(xml_file): def _from_file(xml): """ Recursivly parse the xml tree into nested data format. - @param xml the xml tree - @return the nested data + + Args: + xml: the xml tree + + Returns: + the nested data """ tag = xml.tag if not len(xml): @@ -73,8 +83,10 @@ 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. - @param nested_data the nested data - @param xml_file the xml file path + + Args: + nested_data: the nested data + xml_file: the xml file path """ xml = _to_file(nested_data)[0] open(xml_file, 'w').write(etree.tostring(xml, xml_declaration=True, pretty_print=True)) @@ -82,8 +94,12 @@ def to_file(nested_data, xml_file): def _to_file(nested_data): """ Recursivly parse the nested data into xml tree format. - @param nested_data the nested data - @return the xml tree filled with child nodes + + Args: + nested_data: the nested data + + Returns: + the xml tree filled with child nodes """ nodes = list() for key, values in nested_data.iteritems(): diff --git a/grc/base/Platform.py b/grc/base/Platform.py index 94d0077ea9..d6a3b5dd28 100644 --- a/grc/base/Platform.py +++ b/grc/base/Platform.py @@ -35,17 +35,21 @@ class Platform(_Element): license='', website=None, colors=[]): """ Make a platform from the arguments. - @param name the platform name - @param version the version string - @param key the unique platform key - @param block_paths the file paths to blocks in this platform - @param block_dtd the dtd validator for xml block wrappers - @param default_flow_graph the default flow graph file path - @param generator the generator class for this platform - @param colors a list of title, color_spec tuples - @param license a multi-line license (first line is copyright) - @param website the website url for this platform - @return a platform object + + Args: + name: the platform name + version: the version string + key: the unique platform key + block_paths: the file paths to blocks in this platform + block_dtd: the dtd validator for xml block wrappers + default_flow_graph: the default flow graph file path + generator: the generator class for this platform + 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 """ _Element.__init__(self) self._name = name @@ -100,8 +104,12 @@ class Platform(_Element): """ Parse a saved flow graph file. Ensure that the file exists, and passes the dtd check. - @param flow_graph_file the flow graph file - @return nested data + + Args: + flow_graph_file: the flow graph file + + Returns: + nested data @throws exception if the validation fails """ flow_graph_file = flow_graph_file or self._default_flow_graph @@ -114,7 +122,9 @@ 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. - @param block_tree the block tree object + + Args: + block_tree: the block tree object """ #recursive function to load categories and blocks def load_category(cat_n, parent=[]): diff --git a/grc/base/Port.py b/grc/base/Port.py index 7a1b5d4e69..0e58f583c3 100644 --- a/grc/base/Port.py +++ b/grc/base/Port.py @@ -24,9 +24,11 @@ class Port(Element): def __init__(self, block, n, dir): """ Make a new port from nested data. - @param block the parent element - @param n the nested odict - @param dir the direction source or sink + + Args: + block: the parent element + n: the nested odict + dir: the direction source or sink """ #build the port Element.__init__(self, block) @@ -69,7 +71,9 @@ class Port(Element): def get_connections(self): """ Get all connections that use this port. - @return a list of connection objects + + Returns: + a list of connection objects """ connections = self.get_parent().get_parent().get_connections() connections = filter(lambda c: c.get_source() is self or c.get_sink() is self, connections) @@ -78,6 +82,8 @@ class Port(Element): def get_enabled_connections(self): """ Get all enabled connections that use this port. - @return a list of connection objects + + Returns: + a list of connection objects """ return filter(lambda c: c.get_enabled(), self.get_connections()) diff --git a/grc/base/odict.py b/grc/base/odict.py index 044d04ad78..302583163b 100644 --- a/grc/base/odict.py +++ b/grc/base/odict.py @@ -50,9 +50,11 @@ 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. - @param pos_key the positional key - @param key the key for the new entry - @param val the value for the new entry + + Args: + pos_key: the positional key + key: the key for the new entry + val: the value for the new entry """ index = (pos_key is None) and len(self._keys) or self._keys.index(pos_key) if key in self._keys: raise KeyError('Cannot insert, key "%s" already exists'%str(key)) @@ -63,9 +65,11 @@ 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. - @param pos_key the positional key - @param key the key for the new entry - @param val the value for the new entry + + Args: + pos_key: the positional key + key: the key for the new entry + val: the value for the new entry """ index = (pos_key is not None) and self._keys.index(pos_key) or 0 if key in self._keys: raise KeyError('Cannot insert, key "%s" already exists'%str(key)) @@ -75,8 +79,12 @@ class odict(DictMixin): def find(self, key): """ Get the value for this key if exists. - @param key the key to search for - @return the value or None + + Args: + key: the key to search for + + Returns: + the value or None """ if self.has_key(key): return self[key] return None @@ -84,8 +92,12 @@ class odict(DictMixin): def findall(self, key): """ Get a list of values for this key. - @param key the key to search for - @return a list of values or empty list + + Args: + key: the key to search for + + Returns: + a list of values or empty list """ obj = self.find(key) if obj is None: obj = list() diff --git a/grc/grc_gnuradio/blks2/error_rate.py b/grc/grc_gnuradio/blks2/error_rate.py index 9b2df58ef1..eb8d12d4e3 100644 --- a/grc/grc_gnuradio/blks2/error_rate.py +++ b/grc/grc_gnuradio/blks2/error_rate.py @@ -62,9 +62,11 @@ class error_rate(gr.hier_block2): def __init__(self, type='BER', win_size=default_win_size, bits_per_symbol=2): """ Error rate constructor. - @param type a string 'BER' or 'SER' - @param win_size the number of samples to calculate over - @param bits_per_symbol the number of information bits per symbol (BER only) + + Args: + type: a string 'BER' or 'SER' + win_size: the number of samples to calculate over + bits_per_symbol: the number of information bits per symbol (BER only) """ #init gr.hier_block2.__init__( diff --git a/grc/grc_gnuradio/blks2/packet.py b/grc/grc_gnuradio/blks2/packet.py index 494afa986a..cceb4da650 100644 --- a/grc/grc_gnuradio/blks2/packet.py +++ b/grc/grc_gnuradio/blks2/packet.py @@ -70,11 +70,13 @@ class packet_encoder(gr.hier_block2): def __init__(self, samples_per_symbol, bits_per_symbol, access_code='', pad_for_usrp=True): """ packet_mod constructor. - @param samples_per_symbol number of samples per symbol - @param bits_per_symbol number of bits per symbol - @param access_code AKA sync vector - @param pad_for_usrp If true, packets are padded such that they end up a multiple of 128 samples - @param payload_length number of bytes in a data-stream slice + + Args: + samples_per_symbol: number of samples per symbol + bits_per_symbol: number of bits per symbol + access_code: AKA sync vector + pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples + payload_length: number of bytes in a data-stream slice """ #setup parameters self._samples_per_symbol = samples_per_symbol @@ -102,7 +104,9 @@ class packet_encoder(gr.hier_block2): def send_pkt(self, payload): """ Wrap the payload in a packet and push onto the message queue. - @param payload string, data to send + + Args: + payload: string, data to send """ packet = packet_utils.make_packet( payload, @@ -142,9 +146,11 @@ class packet_decoder(gr.hier_block2): def __init__(self, access_code='', threshold=-1, callback=None): """ packet_demod constructor. - @param access_code AKA sync vector - @param threshold detect access_code with up to threshold bits wrong (0 -> use default) - @param callback a function of args: ok, payload + + Args: + access_code: AKA sync vector + threshold: detect access_code with up to threshold bits wrong (0 -> use default) + callback: a function of args: ok, payload """ #access code if not access_code: #get access code diff --git a/grc/grc_gnuradio/blks2/selector.py b/grc/grc_gnuradio/blks2/selector.py index f0f6d5dd7a..f6a8aa79b1 100644 --- a/grc/grc_gnuradio/blks2/selector.py +++ b/grc/grc_gnuradio/blks2/selector.py @@ -26,11 +26,13 @@ class selector(gr.hier_block2): def __init__(self, item_size, num_inputs, num_outputs, input_index, output_index): """ Selector constructor. - @param item_size the size of the gr data stream in bytes - @param num_inputs the number of inputs (integer) - @param num_outputs the number of outputs (integer) - @param input_index the index for the source data - @param output_index the index for the destination data + + Args: + item_size: the size of the gr data stream in bytes + num_inputs: the number of inputs (integer) + num_outputs: the number of outputs (integer) + input_index: the index for the source data + output_index: the index for the destination data """ gr.hier_block2.__init__( self, 'selector', @@ -54,7 +56,9 @@ class selector(gr.hier_block2): def _indexes_valid(self): """ Are the input and output indexes within range of the number of inputs and outputs? - @return true if input index and output index are in range + + Returns: + true if input index and output index are in range """ return self.input_index in range(self.num_inputs) and self.output_index in range(self.num_outputs) @@ -84,7 +88,9 @@ class selector(gr.hier_block2): def set_input_index(self, input_index): """ Change the block to the new input index if the index changed. - @param input_index the new input index + + Args: + input_index: the new input index """ if self.input_index != input_index: self.lock() @@ -96,7 +102,9 @@ class selector(gr.hier_block2): def set_output_index(self, output_index): """ Change the block to the new output index if the index changed. - @param output_index the new output index + + Args: + output_index: the new output index """ if self.output_index != output_index: self.lock() @@ -111,8 +119,10 @@ class valve(selector): def __init__(self, item_size, open): """ Constructor for valve. - @param item_size the size of the gr data stream in bytes - @param open true if initial valve state is open + + Args: + item_size: the size of the gr data stream in bytes + open: true if initial valve state is open """ if open: output_index = -1 else: output_index = 0 @@ -121,7 +131,9 @@ class valve(selector): def set_open(self, open): """ Callback to set open state. - @param open true to set valve state to open + + Args: + open: true to set valve state to open """ if open: output_index = -1 else: output_index = 0 diff --git a/grc/grc_gnuradio/blks2/tcp.py b/grc/grc_gnuradio/blks2/tcp.py index c6739b711e..dfebfcc2e6 100644 --- a/grc/grc_gnuradio/blks2/tcp.py +++ b/grc/grc_gnuradio/blks2/tcp.py @@ -28,10 +28,14 @@ def _get_sock_fd(addr, port, server): Get the file descriptor for the socket. As a client, block on connect, dup the socket descriptor. As a server, block on accept, dup the client descriptor. - @param addr the ip address string - @param port the tcp port number - @param server true for server mode, false for client mode - @return the file descriptor number + + Args: + addr: the ip address string + port: the tcp port number + server: true for server mode, false for client mode + + Returns: + the file descriptor number """ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if server: diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index 476c82b4f6..bb687529f2 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -47,8 +47,10 @@ class ActionHandler: ActionHandler constructor. Create the main window, setup the message handler, import the preferences, and connect all of the action handlers. Finally, enter the gtk main loop and block. - @param file_paths a list of flow graph file passed from command line - @param platform platform module + + Args: + file_paths: a list of flow graph file passed from command line + platform: platform module """ self.clipboard = None for action in Actions.get_all_actions(): action.connect('activate', self._handle_action) @@ -76,7 +78,9 @@ class ActionHandler: * some keys are ignored by the accelerators like the direction keys, * some keys are not registered to any accelerators but are still used. When not in focus, gtk and the accelerators handle the the key press. - @return false to let gtk handle the key action + + Returns: + false to let gtk handle the key action """ if not self.get_focus_flag(): return False return Actions.handle_key_press(event) @@ -86,7 +90,9 @@ class ActionHandler: Handle the delete event from the main window. Generated by pressing X to close, alt+f4, or right click+close. This method in turns calls the state handler to quit. - @return true + + Returns: + true """ Actions.APPLICATION_QUIT() return True @@ -350,7 +356,9 @@ class ExecFlowGraphThread(Thread): def __init__ (self, action_handler): """ ExecFlowGraphThread constructor. - @param action_handler an instance of an ActionHandler + + Args: + action_handler: an instance of an ActionHandler """ Thread.__init__(self) self.update_exec_stop = action_handler.update_exec_stop diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py index 4d196477eb..2a8676e9b4 100644 --- a/grc/gui/Actions.py +++ b/grc/gui/Actions.py @@ -33,8 +33,12 @@ def handle_key_press(event): """ Call the action associated with the key press event. Both the key value and the mask must have a match. - @param event a gtk key press event - @return true if handled + + Args: + event: a gtk key press event + + Returns: + true if handled """ _used_mods_mask = reduce(lambda x, y: x | y, [mod_mask for keyval, mod_mask in _actions_keypress_dict], NO_MODS_MASK) #extract the key value and the consumed modifiers @@ -63,8 +67,10 @@ class Action(gtk.Action): def __init__(self, keypresses=(), name=None, label=None, tooltip=None, stock_id=None): """ Create a new Action instance. - @param key_presses a tuple of (keyval1, mod_mask1, keyval2, mod_mask2, ...) - @param the regular gtk.Action parameters (defaults to None) + + Args: + key_presses: a tuple of (keyval1, mod_mask1, keyval2, mod_mask2, ...) + the: regular gtk.Action parameters (defaults to None) """ if name is None: name = label gtk.Action.__init__(self, diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 27143e0704..11e66bff85 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -69,7 +69,9 @@ class Block(Element): def get_coordinate(self): """ Get the coordinate from the position param. - @return the coordinate tuple (x, y) or (0, 0) if failure + + Returns: + the coordinate tuple (x, y) or (0, 0) if failure """ try: #should evaluate to tuple coor = eval(self.get_param('_coordinate').get_value()) @@ -91,14 +93,18 @@ class Block(Element): def set_coordinate(self, coor): """ Set the coordinate into the position param. - @param coor the coordinate tuple (x, y) + + Args: + coor: the coordinate tuple (x, y) """ self.get_param('_coordinate').set_value(str(coor)) def get_rotation(self): """ Get the rotation from the position param. - @return the rotation in degrees or 0 if failure + + Returns: + the rotation in degrees or 0 if failure """ try: #should evaluate to dict rotation = eval(self.get_param('_rotation').get_value()) @@ -110,7 +116,9 @@ class Block(Element): def set_rotation(self, rot): """ Set the rotation into the position param. - @param rot the rotation in degrees + + Args: + rot: the rotation in degrees """ self.get_param('_rotation').set_value(str(rot)) @@ -171,8 +179,10 @@ class Block(Element): def draw(self, gc, window): """ Draw the signal block with label and inputs/outputs. - @param gc the graphics context - @param window the gtk window to draw on + + Args: + gc: the graphics context + window: the gtk window to draw on """ x, y = self.get_coordinate() #draw main block @@ -191,9 +201,13 @@ class Block(Element): def what_is_selected(self, coor, coor_m=None): """ Get the element that is selected. - @param coor the (x,y) tuple - @param coor_m the (x_m, y_m) tuple - @return this block, a port, or None + + Args: + coor: the (x,y) tuple + coor_m: the (x_m, y_m) tuple + + Returns: + this block, a port, or None """ for port in self.get_ports(): port_selected = port.what_is_selected(coor, coor_m) diff --git a/grc/gui/BlockTreeWindow.py b/grc/gui/BlockTreeWindow.py index 0175c8becf..e5a4027eb8 100644 --- a/grc/gui/BlockTreeWindow.py +++ b/grc/gui/BlockTreeWindow.py @@ -46,8 +46,10 @@ class BlockTreeWindow(gtk.VBox): Create a tree view of the possible blocks in the platform. The tree view nodes will be category names, the leaves will be block names. A mouse double click or button press action will trigger the add block event. - @param platform the particular platform will all block prototypes - @param get_flow_graph get the selected flow graph + + Args: + platform: the particular platform will all block prototypes + get_flow_graph: get the selected flow graph """ gtk.VBox.__init__(self) self.platform = platform @@ -97,8 +99,10 @@ class BlockTreeWindow(gtk.VBox): """ Add a block with category to this selection window. Add only the category when block is None. - @param category the category list or path string - @param block the block object or None + + Args: + category: the category list or path string + block: the block object or None """ if isinstance(category, str): category = category.split('/') category = tuple(filter(lambda x: x, category)) #tuple is hashable @@ -124,7 +128,9 @@ class BlockTreeWindow(gtk.VBox): def _get_selected_block_key(self): """ Get the currently selected block key. - @return the key of the selected block or a empty string + + Returns: + the key of the selected block or a empty string """ selection = self.treeview.get_selection() treestore, iter = selection.get_selected() diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py index fabf34ee72..5d24fefded 100644 --- a/grc/gui/Connection.py +++ b/grc/gui/Connection.py @@ -38,7 +38,9 @@ class Connection(Element): """ Get the 0,0 coordinate. Coordinates are irrelevant in connection. - @return 0, 0 + + Returns: + 0, 0 """ return (0, 0) @@ -46,7 +48,9 @@ class Connection(Element): """ Get the 0 degree rotation. Rotations are irrelevant in connection. - @return 0 + + Returns: + 0 """ return 0 @@ -120,8 +124,10 @@ class Connection(Element): def draw(self, gc, window): """ Draw the connection. - @param gc the graphics context - @param window the gtk window to draw on + + Args: + gc: the graphics context + window: the gtk window to draw on """ sink = self.get_sink() source = self.get_source() diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py index 473c796aff..df424750b9 100644 --- a/grc/gui/Dialogs.py +++ b/grc/gui/Dialogs.py @@ -28,7 +28,9 @@ class TextDisplay(gtk.TextView): def __init__(self, text=''): """ TextDisplay constructor. - @param text the text to display (string) + + Args: + text: the text to display (string) """ text_buffer = gtk.TextBuffer() text_buffer.set_text(text) @@ -42,12 +44,18 @@ class TextDisplay(gtk.TextView): def MessageDialogHelper(type, buttons, title=None, markup=None): """ Create a modal message dialog and run it. - @param type the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR - @param buttons the predefined set of buttons to use: + + Args: + type: the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR + buttons: the predefined set of buttons to use: gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL - @param tittle the title of the window (string) - @param markup the message text with pango markup - @return the gtk response from run() + + Args: + tittle: the title of the window (string) + markup: the message text with pango markup + + Returns: + the gtk response from run() """ message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type, buttons) if title: message_dialog.set_title(title) diff --git a/grc/gui/DrawingArea.py b/grc/gui/DrawingArea.py index 790df7c3fa..da16eb7cf2 100644 --- a/grc/gui/DrawingArea.py +++ b/grc/gui/DrawingArea.py @@ -32,7 +32,9 @@ class DrawingArea(gtk.DrawingArea): """ DrawingArea contructor. Connect event handlers. - @param main_window the main_window containing all flow graphs + + Args: + main_window: the main_window containing all flow graphs """ self.ctrl_mask = False self._flow_graph = flow_graph diff --git a/grc/gui/Element.py b/grc/gui/Element.py index e020c5caa9..eac59d88eb 100644 --- a/grc/gui/Element.py +++ b/grc/gui/Element.py @@ -40,8 +40,12 @@ class Element(object): """ Is this element horizontal? If rotation is None, use this element's rotation. - @param rotation the optional rotation - @return true if rotation is horizontal + + Args: + rotation: the optional rotation + + Returns: + true if rotation is horizontal """ rotation = rotation or self.get_rotation() return rotation in (0, 180) @@ -50,8 +54,12 @@ class Element(object): """ Is this element vertical? If rotation is None, use this element's rotation. - @param rotation the optional rotation - @return true if rotation is vertical + + Args: + rotation: the optional rotation + + Returns: + true if rotation is vertical """ rotation = rotation or self.get_rotation() return rotation in (90, 270) @@ -74,10 +82,12 @@ class Element(object): def draw(self, gc, window, border_color, bg_color): """ Draw in the given window. - @param gc the graphics context - @param window the gtk window to draw on - @param border_color the color for lines and rectangle borders - @param bg_color the color for the inside of the rectangle + + Args: + gc: the graphics context + window: the gtk window to draw on + border_color: the color for lines and rectangle borders + bg_color: the color for the inside of the rectangle """ X,Y = self.get_coordinate() for (rX,rY),(W,H) in self._areas_list: @@ -94,7 +104,9 @@ class Element(object): def rotate(self, rotation): """ Rotate all of the areas by 90 degrees. - @param rotation multiple of 90 degrees + + Args: + rotation: multiple of 90 degrees """ self.set_rotation((self.get_rotation() + rotation)%360) @@ -106,41 +118,53 @@ class Element(object): def set_coordinate(self, coor): """ Set the reference coordinate. - @param coor the coordinate tuple (x,y) + + Args: + coor: the coordinate tuple (x,y) """ self.coor = coor def get_parent(self): """ Get the parent of this element. - @return the parent + + Returns: + the parent """ return self.parent def set_highlighted(self, highlighted): """ Set the highlight status. - @param highlighted true to enable highlighting + + Args: + highlighted: true to enable highlighting """ self.highlighted = highlighted def is_highlighted(self): """ Get the highlight status. - @return true if highlighted + + Returns: + true if highlighted """ return self.highlighted def get_coordinate(self): """Get the coordinate. - @return the coordinate tuple (x,y) + + Returns: + the coordinate tuple (x,y) """ return self.coor def move(self, delta_coor): """ Move the element by adding the delta_coor to the current coordinate. - @param delta_coor (delta_x,delta_y) tuple + + Args: + delta_coor: (delta_x,delta_y) tuple """ deltaX, deltaY = delta_coor X, Y = self.get_coordinate() @@ -154,8 +178,10 @@ class Element(object): A positive width is to the right of the coordinate. A positive height is above the coordinate. The area is associated with a rotation. - @param rel_coor (x,y) offset from this element's coordinate - @param area (width,height) tuple + + Args: + rel_coor: (x,y) offset from this element's coordinate + area: (width,height) tuple """ self._areas_list.append((rel_coor, area)) @@ -165,8 +191,10 @@ class Element(object): A line is defined by 2 relative coordinates. Lines must be horizontal or vertical. The line is associated with a rotation. - @param rel_coor1 relative (x1,y1) tuple - @param rel_coor2 relative (x2,y2) tuple + + Args: + rel_coor1: relative (x1,y1) tuple + rel_coor2: relative (x2,y2) tuple """ self._lines_list.append((rel_coor1, rel_coor2)) @@ -178,9 +206,13 @@ class Element(object): Both coordinates specified: Is this element within the rectangular region defined by both coordinates? ie: do any area corners or line endpoints fall within the region? - @param coor the selection coordinate, tuple x, y - @param coor_m an additional selection coordinate. - @return self if one of the areas/lines encompasses coor, else None. + + Args: + coor: the selection coordinate, tuple x, y + coor_m: an additional selection coordinate. + + Returns: + self if one of the areas/lines encompasses coor, else None. """ #function to test if p is between a and b (inclusive) in_between = lambda p, a, b: p >= min(a, b) and p <= max(a, b) @@ -215,14 +247,18 @@ class Element(object): def get_rotation(self): """ Get the rotation in degrees. - @return the rotation + + Returns: + the rotation """ return self.rotation def set_rotation(self, rotation): """ Set the rotation in degrees. - @param rotation the rotation""" + + Args: + rotation: the rotation""" if rotation not in POSSIBLE_ROTATIONS: raise Exception('"%s" is not one of the possible rotations: (%s)'%(rotation, POSSIBLE_ROTATIONS)) self.rotation = rotation diff --git a/grc/gui/FileDialogs.py b/grc/gui/FileDialogs.py index 3b210c33f3..20172a7418 100644 --- a/grc/gui/FileDialogs.py +++ b/grc/gui/FileDialogs.py @@ -79,8 +79,10 @@ class FileDialogHelper(gtk.FileChooserDialog): FileDialogHelper contructor. Create a save or open dialog with cancel and ok buttons. Use standard settings: no multiple selection, local files only, and the * filter. - @param action gtk.FILE_CHOOSER_ACTION_OPEN or gtk.FILE_CHOOSER_ACTION_SAVE - @param title the title of the dialog (string) + + Args: + action: gtk.FILE_CHOOSER_ACTION_OPEN or gtk.FILE_CHOOSER_ACTION_SAVE + title: the title of the dialog (string) """ ok_stock = {gtk.FILE_CHOOSER_ACTION_OPEN : 'gtk-open', gtk.FILE_CHOOSER_ACTION_SAVE : 'gtk-save'}[action] gtk.FileChooserDialog.__init__(self, title, None, action, ('gtk-cancel', gtk.RESPONSE_CANCEL, ok_stock, gtk.RESPONSE_OK)) @@ -94,7 +96,9 @@ class FileDialog(FileDialogHelper): def __init__(self, current_file_path=''): """ FileDialog constructor. - @param current_file_path the current directory or path to the open flow graph + + Args: + current_file_path: the current directory or path to the open flow graph """ if not current_file_path: current_file_path = path.join(DEFAULT_FILE_PATH, NEW_FLOGRAPH_TITLE + Preferences.file_extension()) if self.type == OPEN_FLOW_GRAPH: @@ -115,7 +119,9 @@ class FileDialog(FileDialogHelper): def add_and_set_filter(self, filter): """ Add the gtk file filter to the list of filters and set it as the default file filter. - @param filter a gtk file filter. + + Args: + filter: a gtk file filter. """ self.add_filter(filter) self.set_filter(filter) @@ -126,7 +132,9 @@ class FileDialog(FileDialogHelper): If this is a save dialog and the file name is missing the extension, append the file extension. If the file name with the extension already exists, show a overwrite dialog. If this is an open dialog, return a list of filenames. - @return the complete file path + + Returns: + the complete file path """ if gtk.FileChooserDialog.run(self) != gtk.RESPONSE_OK: return None #response was cancel ############################################# @@ -164,7 +172,9 @@ class FileDialog(FileDialogHelper): def run(self): """ Get the filename and destroy the dialog. - @return the filename or None if a close/cancel occured. + + Returns: + the filename or None if a close/cancel occured. """ filename = self.get_rectified_filename() self.destroy() diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index 9f3326adaf..418366dbb8 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -79,8 +79,10 @@ class FlowGraph(Element): def add_new_block(self, key, coor=None): """ Add a block of the given key to this flow graph. - @param key the block key - @param coor an optional coordinate or None for random + + Args: + key: the block key + coor: an optional coordinate or None for random """ id = self._get_unique_id(key) #calculate the position coordinate @@ -103,7 +105,9 @@ class FlowGraph(Element): def copy_to_clipboard(self): """ Copy the selected blocks and connections into the clipboard. - @return the clipboard + + Returns: + the clipboard """ #get selected blocks blocks = self.get_selected_blocks() @@ -129,7 +133,9 @@ class FlowGraph(Element): def paste_from_clipboard(self, clipboard): """ Paste the blocks and connections from the clipboard. - @param clipboard the nested data of blocks, connections + + Args: + clipboard: the nested data of blocks, connections """ selected = set() (x_min, y_min), blocks_n, connections_n = clipboard @@ -177,24 +183,36 @@ class FlowGraph(Element): def type_controller_modify_selected(self, direction): """ Change the registered type controller for the selected signal blocks. - @param direction +1 or -1 - @return true for change + + Args: + direction: +1 or -1 + + Returns: + true for change """ return any([sb.type_controller_modify(direction) for sb in self.get_selected_blocks()]) def port_controller_modify_selected(self, direction): """ Change port controller for the selected signal blocks. - @param direction +1 or -1 - @return true for changed + + Args: + direction: +1 or -1 + + Returns: + true for changed """ return any([sb.port_controller_modify(direction) for sb in self.get_selected_blocks()]) def enable_selected(self, enable): """ Enable/disable the selected blocks. - @param enable true to enable - @return true if changed + + Args: + enable: true to enable + + Returns: + true if changed """ changed = False for selected_block in self.get_selected_blocks(): @@ -206,7 +224,9 @@ class FlowGraph(Element): def move_selected(self, delta_coordinate): """ Move the element and by the change in coordinates. - @param delta_coordinate the change in coordinates + + Args: + delta_coordinate: the change in coordinates """ for selected_block in self.get_selected_blocks(): selected_block.move(delta_coordinate) @@ -215,8 +235,12 @@ class FlowGraph(Element): def rotate_selected(self, rotation): """ Rotate the selected blocks by multiples of 90 degrees. - @param rotation the rotation in degrees - @return true if changed, otherwise false. + + Args: + rotation: the rotation in degrees + + Returns: + true if changed, otherwise false. """ if not self.get_selected_blocks(): return False #initialize min and max coordinates @@ -241,7 +265,9 @@ class FlowGraph(Element): def remove_selected(self): """ Remove selected elements - @return true if changed. + + Returns: + true if changed. """ changed = False for selected_element in self.get_selected_elements(): @@ -325,9 +351,13 @@ class FlowGraph(Element): Iterate though the elements backwards since top elements are at the end of the list. If an element is selected, place it at the end of the list so that is is drawn last, and hence on top. Update the selected port information. - @param coor the coordinate of the mouse click - @param coor_m the coordinate for multi select - @return the selected blocks and connections or an empty list + + Args: + coor: the coordinate of the mouse click + coor_m: the coordinate for multi select + + Returns: + the selected blocks and connections or an empty list """ selected_port = None selected = set() @@ -353,7 +383,9 @@ class FlowGraph(Element): def get_selected_connections(self): """ Get a group of selected connections. - @return sub set of connections in this flow graph + + Returns: + sub set of connections in this flow graph """ selected = set() for selected_element in self.get_selected_elements(): @@ -363,7 +395,9 @@ class FlowGraph(Element): def get_selected_blocks(self): """ Get a group of selected blocks. - @return sub set of blocks in this flow graph + + Returns: + sub set of blocks in this flow graph """ selected = set() for selected_element in self.get_selected_elements(): @@ -373,21 +407,27 @@ class FlowGraph(Element): def get_selected_block(self): """ Get the selected block when a block or port is selected. - @return a block or None + + Returns: + a block or None """ return self.get_selected_blocks() and self.get_selected_blocks()[0] or None def get_selected_elements(self): """ Get the group of selected elements. - @return sub set of elements in this flow graph + + Returns: + sub set of elements in this flow graph """ return self._selected_elements def get_selected_element(self): """ Get the selected element. - @return a block, port, or connection or None + + Returns: + a block, port, or connection or None """ return self.get_selected_elements() and self.get_selected_elements()[0] or None diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py index 2f761df1f8..4c2a3ae2d2 100644 --- a/grc/gui/MainWindow.py +++ b/grc/gui/MainWindow.py @@ -118,7 +118,9 @@ class MainWindow(gtk.Window): Handle the delete event from the main window. Generated by pressing X to close, alt+f4, or right click+close. This method in turns calls the state handler to quit. - @return true + + Returns: + true """ Actions.APPLICATION_QUIT() return True @@ -128,9 +130,11 @@ class MainWindow(gtk.Window): Handle a page change. When the user clicks on a new tab, reload the flow graph to update the vars window and call handle states (select nothing) to update the buttons. - @param notebook the notebook - @param page new page - @param page_num new page number + + Args: + notebook: the notebook + page: new page + page_num: new page number """ self.current_page = self.notebook.get_nth_page(page_num) Messages.send_page_switch(self.current_page.get_file_path()) @@ -143,7 +147,9 @@ class MainWindow(gtk.Window): def add_report_line(self, line): """ Place line at the end of the text buffer, then scroll its window all the way down. - @param line the new text + + Args: + line: the new text """ self.text_display.insert(line) vadj = self.reports_scrolled_window.get_vadjustment() @@ -158,8 +164,10 @@ class MainWindow(gtk.Window): """ Create a new notebook page. Set the tab to be selected. - @param file_path optional file to load into the flow graph - @param show true if the page should be shown after loading + + Args: + file_path: optional file to load into the flow graph + show: true if the page should be shown after loading """ #if the file is already open, show the open page and return if file_path and file_path in self._get_files(): #already open @@ -189,7 +197,9 @@ class MainWindow(gtk.Window): def close_pages(self): """ Close all the pages in this notebook. - @return true if all closed + + Returns: + true if all closed """ open_files = filter(lambda file: file, self._get_files()) #filter blank files open_file = self.get_page().get_file_path() @@ -212,7 +222,9 @@ class MainWindow(gtk.Window): Close the current page. If the notebook becomes empty, and ensure is true, call new page upon exit to ensure that at least one page exists. - @param ensure boolean + + Args: + ensure: boolean """ if not self.page_to_be_closed: self.page_to_be_closed = self.get_page() #show the page if it has an executing flow graph or is unsaved @@ -240,7 +252,9 @@ class MainWindow(gtk.Window): Set the title of the main window. Set the titles on the page tabs. Show/hide the reports window. - @param title the window title + + Args: + title: the window title """ gtk.Window.set_title(self, Utils.parse_template(MAIN_WINDOW_TITLE_TMPL, basename=os.path.basename(self.get_page().get_file_path()), @@ -266,21 +280,27 @@ class MainWindow(gtk.Window): def get_page(self): """ Get the selected page. - @return the selected page + + Returns: + the selected page """ return self.current_page def get_flow_graph(self): """ Get the selected flow graph. - @return the selected flow graph + + Returns: + the selected flow graph """ return self.get_page().get_flow_graph() def get_focus_flag(self): """ Get the focus flag from the current page. - @return the focus flag + + Returns: + the focus flag """ return self.get_page().get_drawing_area().get_focus_flag() @@ -291,7 +311,9 @@ class MainWindow(gtk.Window): def _set_page(self, page): """ Set the current page. - @param page the page widget + + Args: + page: the page widget """ self.current_page = page self.notebook.set_current_page(self.notebook.page_num(self.current_page)) @@ -299,7 +321,9 @@ class MainWindow(gtk.Window): def _save_changes(self): """ Save changes to flow graph? - @return true if yes + + Returns: + true if yes """ return MessageDialogHelper( gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, 'Unsaved Changes!', @@ -309,13 +333,17 @@ class MainWindow(gtk.Window): def _get_files(self): """ Get the file names for all the pages, in order. - @return list of file paths + + Returns: + list of file paths """ return map(lambda page: page.get_file_path(), self._get_pages()) def _get_pages(self): """ Get a list of all pages in the notebook. - @return list of pages + + Returns: + list of pages """ return [self.notebook.get_nth_page(page_num) for page_num in range(self.notebook.get_n_pages())] diff --git a/grc/gui/Messages.py b/grc/gui/Messages.py index e98e897aa6..a9f0e36b85 100644 --- a/grc/gui/Messages.py +++ b/grc/gui/Messages.py @@ -26,14 +26,18 @@ MESSENGERS_LIST = list() def register_messenger(messenger): """ Append the given messenger to the list of messengers. - @param messenger a method thats takes a string + + Args: + messenger: a method thats takes a string """ MESSENGERS_LIST.append(messenger) def send(message): """ Give the message to each of the messengers. - @param message a message string + + Args: + message: a message string """ for messenger in MESSENGERS_LIST: messenger(message) diff --git a/grc/gui/NotebookPage.py b/grc/gui/NotebookPage.py index 86b6f1513c..095c045a66 100644 --- a/grc/gui/NotebookPage.py +++ b/grc/gui/NotebookPage.py @@ -36,8 +36,10 @@ class NotebookPage(gtk.HBox): def __init__(self, main_window, flow_graph, file_path=''): """ Page constructor. - @param main_window main window - @param file_path path to a flow graph file + + Args: + main_window: main window + file_path: path to a flow graph file """ self._flow_graph = flow_graph self.set_proc(None) @@ -89,7 +91,9 @@ class NotebookPage(gtk.HBox): def get_generator(self): """ Get the generator object for this flow graph. - @return generator + + Returns: + generator """ return self.get_flow_graph().get_parent().get_generator()( self.get_flow_graph(), @@ -100,7 +104,9 @@ class NotebookPage(gtk.HBox): """ The button was clicked. Make the current page selected, then close. - @param the button + + Args: + the: button """ self.main_window.page_to_be_closed = self Actions.FLOW_GRAPH_CLOSE() @@ -108,35 +114,45 @@ class NotebookPage(gtk.HBox): def set_markup(self, markup): """ Set the markup in this label. - @param markup the new markup text + + Args: + markup: the new markup text """ self.label.set_markup(markup) def get_tab(self): """ Get the gtk widget for this page's tab. - @return gtk widget + + Returns: + gtk widget """ return self.tab def get_proc(self): """ Get the subprocess for the flow graph. - @return the subprocess object + + Returns: + the subprocess object """ return self.process def set_proc(self, process): """ Set the subprocess object. - @param process the new subprocess + + Args: + process: the new subprocess """ self.process = process def get_flow_graph(self): """ Get the flow graph. - @return the flow graph + + Returns: + the flow graph """ return self._flow_graph @@ -144,7 +160,9 @@ class NotebookPage(gtk.HBox): """ Get the read-only state of the file. Always false for empty path. - @return true for read-only + + Returns: + true for read-only """ if not self.get_file_path(): return False return os.path.exists(self.get_file_path()) and \ @@ -153,14 +171,18 @@ class NotebookPage(gtk.HBox): def get_file_path(self): """ Get the file path for the flow graph. - @return the file path or '' + + Returns: + the file path or '' """ return self.file_path def set_file_path(self, file_path=''): """ Set the file path, '' for no file path. - @param file_path file path string + + Args: + file_path: file path string """ if file_path: self.file_path = os.path.abspath(file_path) else: self.file_path = '' @@ -168,20 +190,26 @@ class NotebookPage(gtk.HBox): def get_saved(self): """ Get the saved status for the flow graph. - @return true if saved + + Returns: + true if saved """ return self.saved def set_saved(self, saved=True): """ Set the saved status. - @param saved boolean status + + Args: + saved: boolean status """ self.saved = saved def get_state_cache(self): """ Get the state cache for the flow graph. - @return the state cache + + Returns: + the state cache """ return self.state_cache diff --git a/grc/gui/Param.py b/grc/gui/Param.py index cb6c663e30..da76b6b82c 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -175,7 +175,9 @@ class Param(Element): An enum requires and combo parameter. A non-enum with options gets a combined entry/combo parameter. All others get a standard entry parameter. - @return gtk input class + + Returns: + gtk input class """ if self.is_enum(): return EnumParam(self, *args, **kwargs) if self.get_options(): return EnumEntryParam(self, *args, **kwargs) @@ -184,6 +186,8 @@ class Param(Element): def get_markup(self): """ Get the markup for this param. - @return a pango markup string + + Returns: + a pango markup string """ return Utils.parse_template(PARAM_MARKUP_TMPL, param=self) diff --git a/grc/gui/Port.py b/grc/gui/Port.py index 2896d04c18..7b4c27dd5f 100644 --- a/grc/gui/Port.py +++ b/grc/gui/Port.py @@ -106,8 +106,10 @@ class Port(Element): def draw(self, gc, window): """ Draw the socket with a label. - @param gc the graphics context - @param window the gtk window to draw on + + Args: + gc: the graphics context + window: the gtk window to draw on """ Element.draw( self, gc, window, bg_color=self._bg_color, @@ -123,7 +125,9 @@ class Port(Element): def get_connector_coordinate(self): """ Get the coordinate where connections may attach to. - @return the connector coordinate (x, y) tuple + + Returns: + the connector coordinate (x, y) tuple """ x,y = self._connector_coordinate X,Y = self.get_coordinate() @@ -134,7 +138,9 @@ class Port(Element): Get the direction that the socket points: 0,90,180,270. This is the rotation degree if the socket is an output or the rotation degree + 180 if the socket is an input. - @return the direction in degrees + + Returns: + the direction in degrees """ if self.is_source(): return self.get_rotation() elif self.is_sink(): return (self.get_rotation() + 180)%360 @@ -143,48 +149,62 @@ class Port(Element): """ Get the length of the connector. The connector length increases as the port index changes. - @return the length in pixels + + Returns: + the length in pixels """ return self._connector_length def get_rotation(self): """ Get the parent's rotation rather than self. - @return the parent's rotation + + Returns: + the parent's rotation """ return self.get_parent().get_rotation() def move(self, delta_coor): """ Move the parent rather than self. - @param delta_corr the (delta_x, delta_y) tuple + + Args: + delta_corr: the (delta_x, delta_y) tuple """ self.get_parent().move(delta_coor) def rotate(self, direction): """ Rotate the parent rather than self. - @param direction degrees to rotate + + Args: + direction: degrees to rotate """ self.get_parent().rotate(direction) def get_coordinate(self): """ Get the parent's coordinate rather than self. - @return the parents coordinate + + Returns: + the parents coordinate """ return self.get_parent().get_coordinate() def set_highlighted(self, highlight): """ Set the parent highlight rather than self. - @param highlight true to enable highlighting + + Args: + highlight: true to enable highlighting """ self.get_parent().set_highlighted(highlight) def is_highlighted(self): """ Get the parent's is highlight rather than self. - @return the parent's highlighting status + + Returns: + the parent's highlighting status """ return self.get_parent().is_highlighted() diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index cc84fd0888..5264857fab 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -28,8 +28,12 @@ def get_title_label(title): """ Get a title label for the params window. The title will be bold, underlined, and left justified. - @param title the text of the title - @return a gtk object + + Args: + title: the text of the title + + Returns: + a gtk object """ label = gtk.Label() label.set_markup('\n<b><span underline="low">%s</span>:</b>\n'%title) @@ -45,7 +49,9 @@ class PropsDialog(gtk.Dialog): def __init__(self, block): """ Properties dialog contructor. - @param block a block instance + + Args: + block: a block instance """ self._hash = 0 LABEL_SPACING = 7 @@ -94,7 +100,9 @@ class PropsDialog(gtk.Dialog): To the props dialog, the hide setting of 'none' and 'part' are identical. Therfore, the props dialog only cares if the hide setting is/not 'all'. Make a hash that uniquely represents the params' state. - @return true if changed + + Returns: + true if changed """ old_hash = self._hash #create a tuple of things from each param that affects the params box @@ -153,7 +161,9 @@ class PropsDialog(gtk.Dialog): """ Handle key presses from the keyboard. Call the ok response when enter is pressed. - @return false to forward the keypress + + Returns: + false to forward the keypress """ if event.keyval == gtk.keysyms.Return: self.response(gtk.RESPONSE_ACCEPT) @@ -163,7 +173,9 @@ class PropsDialog(gtk.Dialog): def run(self): """ Run the dialog and get its response. - @return true if the response was accept + + Returns: + true if the response was accept """ response = gtk.Dialog.run(self) self.destroy() diff --git a/grc/gui/StateCache.py b/grc/gui/StateCache.py index 3f6b792240..50d85bf960 100644 --- a/grc/gui/StateCache.py +++ b/grc/gui/StateCache.py @@ -30,7 +30,9 @@ class StateCache(object): def __init__(self, initial_state): """ StateCache constructor. - @param initial_state the intial state (nested data) + + Args: + initial_state: the intial state (nested data) """ self.states = [None] * STATE_CACHE_SIZE #fill states self.current_state_index = 0 @@ -43,7 +45,9 @@ class StateCache(object): """ Save a new state. Place the new state at the next index and add one to the number of previous states. - @param state the new state + + Args: + state: the new state """ self.current_state_index = (self.current_state_index + 1)%STATE_CACHE_SIZE self.states[self.current_state_index] = state @@ -55,7 +59,9 @@ class StateCache(object): def get_current_state(self): """ Get the state at the current index. - @return the current state (nested data) + + Returns: + the current state (nested data) """ self.update_actions() return self.states[self.current_state_index] @@ -63,7 +69,9 @@ class StateCache(object): def get_prev_state(self): """ Get the previous state and decrement the current index. - @return the previous state or None + + Returns: + the previous state or None """ if self.num_prev_states > 0: self.current_state_index = (self.current_state_index + STATE_CACHE_SIZE -1)%STATE_CACHE_SIZE @@ -75,7 +83,9 @@ class StateCache(object): def get_next_state(self): """ Get the nest state and increment the current index. - @return the next state or None + + Returns: + the next state or None """ if self.num_next_states > 0: self.current_state_index = (self.current_state_index + 1)%STATE_CACHE_SIZE diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py index bb19ed3d96..b68c19c4e1 100644 --- a/grc/gui/Utils.py +++ b/grc/gui/Utils.py @@ -29,10 +29,12 @@ def rotate_pixmap(gc, src_pixmap, dst_pixmap, angle=gtk.gdk.PIXBUF_ROTATE_COUNTE Load the destination pixmap with a rotated version of the source pixmap. The source pixmap will be loaded into a pixbuf, rotated, and drawn to the destination pixmap. The pixbuf is a client-side drawable, where a pixmap is a server-side drawable. - @param gc the graphics context - @param src_pixmap the source pixmap - @param dst_pixmap the destination pixmap - @param angle the angle to rotate by + + Args: + gc: the graphics context + src_pixmap: the source pixmap + dst_pixmap: the destination pixmap + angle: the angle to rotate by """ width, height = src_pixmap.get_size() pixbuf = gtk.gdk.Pixbuf( @@ -47,9 +49,13 @@ def rotate_pixmap(gc, src_pixmap, dst_pixmap, angle=gtk.gdk.PIXBUF_ROTATE_COUNTE def get_rotated_coordinate(coor, rotation): """ Rotate the coordinate by the given rotation. - @param coor the coordinate x, y tuple - @param rotation the angle in degrees - @return the rotated coordinates + + Args: + coor: the coordinate x, y tuple + rotation: the angle in degrees + + Returns: + the rotated coordinates """ #handles negative angles rotation = (rotation + 360)%360 @@ -68,9 +74,13 @@ def get_rotated_coordinate(coor, rotation): def get_angle_from_coordinates((x1,y1), (x2,y2)): """ Given two points, calculate the vector direction from point1 to point2, directions are multiples of 90 degrees. - @param (x1,y1) the coordinate of point 1 - @param (x2,y2) the coordinate of point 2 - @return the direction in degrees + + Args: + (x1,y1): the coordinate of point 1 + (x2,y2): the coordinate of point 2 + + Returns: + the direction in degrees """ if y1 == y2:#0 or 180 if x2 > x1: return 0 @@ -83,8 +93,12 @@ def parse_template(tmpl_str, **kwargs): """ Parse the template string with the given args. Pass in the xml encode method for pango escape chars. - @param tmpl_str the template as a string - @return a string of the parsed template + + Args: + tmpl_str: the template as a string + + Returns: + a string of the parsed template """ kwargs['encode'] = gobject.markup_escape_text return str(Template(tmpl_str, kwargs)) diff --git a/grc/python/Block.py b/grc/python/Block.py index 2c334dfc2c..806de46724 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -34,9 +34,13 @@ class Block(_Block, _GUIBlock): def __init__(self, flow_graph, n): """ Make a new block from nested data. - @param flow graph the parent element - @param n the nested odict - @return block a new block + + Args: + flow: graph the parent element + n: the nested odict + + Returns: + block a new block """ #grab the data self._doc = n.find('doc') or '' @@ -128,8 +132,12 @@ class Block(_Block, _GUIBlock): def port_controller_modify(self, direction): """ Change the port controller. - @param direction +1 or -1 - @return true for change + + Args: + direction: +1 or -1 + + Returns: + true for change """ changed = False #concat the nports string from the private nports settings of all ports @@ -161,7 +169,9 @@ class Block(_Block, _GUIBlock): Split each import statement at newlines. Combine all import statments into a list. Filter empty imports. - @return a list of import statements + + Returns: + a list of import statements """ return filter(lambda i: i, sum(map(lambda i: self.resolve_dependencies(i).split('\n'), self._imports), [])) @@ -171,7 +181,9 @@ class Block(_Block, _GUIBlock): def get_callbacks(self): """ Get a list of function callbacks for this block. - @return a list of strings + + Returns: + a list of strings """ def make_callback(callback): callback = self.resolve_dependencies(callback) diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py index 89a169355b..9d48401ea0 100644 --- a/grc/python/FlowGraph.py +++ b/grc/python/FlowGraph.py @@ -35,10 +35,14 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): def _eval(self, code, namespace, namespace_hash): """ Evaluate the code with the given namespace. - @param code a string with python code - @param namespace a dict representing the namespace - @param namespace_hash a unique hash for the namespace - @return the resultant object + + 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 """ if not code: raise Exception, 'Cannot evaluate empty statement.' my_hash = hash(code) ^ namespace_hash @@ -51,8 +55,12 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): def get_io_signaturev(self, direction): """ Get a list of io signatures for this flow graph. - @param direction a string of 'in' or 'out' - @return a list of dicts with: type, label, vlen, size + + Args: + direction: a string of 'in' or 'out' + + Returns: + a list of dicts with: type, label, vlen, size """ sorted_pads = { 'in': self.get_pad_sources(), @@ -69,7 +77,9 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): def get_pad_sources(self): """ Get a list of pad source blocks sorted by id order. - @return a list of pad source blocks in this flow graph + + Returns: + a list of pad source blocks in this flow graph """ pads = filter(lambda b: b.get_key() == 'pad_source', self.get_enabled_blocks()) return sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id())) @@ -77,7 +87,9 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): def get_pad_sinks(self): """ Get a list of pad sink blocks sorted by id order. - @return a list of pad sink blocks in this flow graph + + Returns: + a list of pad sink blocks in this flow graph """ pads = filter(lambda b: b.get_key() == 'pad_sink', self.get_enabled_blocks()) return sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id())) @@ -85,7 +97,9 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): def get_imports(self): """ Get a set of all import statments in this flow graph namespace. - @return a set of import statements + + Returns: + a set of import statements """ imports = sum([block.get_imports() for block in self.get_enabled_blocks()], []) imports = sorted(set(imports)) @@ -95,7 +109,9 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): """ Get a list of all variables in this flow graph namespace. Exclude paramterized variables. - @return a sorted list of variable blocks in order of dependency (indep -> dep) + + Returns: + a sorted list of variable blocks in order of dependency (indep -> dep) """ variables = filter(lambda b: _variable_matcher.match(b.get_key()), self.get_enabled_blocks()) return expr_utils.sort_objects(variables, lambda v: v.get_id(), lambda v: v.get_var_make()) @@ -103,7 +119,9 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): def get_parameters(self): """ Get a list of all paramterized variables in this flow graph namespace. - @return a list of paramterized variables + + Returns: + a list of paramterized variables """ parameters = filter(lambda b: _parameter_matcher.match(b.get_key()), self.get_enabled_blocks()) return parameters @@ -118,9 +136,13 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): def evaluate(self, expr): """ Evaluate the expression. - @param expr the string expression + + Args: + expr: the string expression @throw Exception bad expression - @return the evaluated data + + Returns: + the evaluated data """ if self._renew_eval_ns: self._renew_eval_ns = False diff --git a/grc/python/Generator.py b/grc/python/Generator.py index 2a6fe51d5d..f8490227a7 100644 --- a/grc/python/Generator.py +++ b/grc/python/Generator.py @@ -35,8 +35,10 @@ class Generator(object): """ Initialize the generator object. Determine the file to generate. - @param flow_graph the flow graph object - @param file_path the path to write the file to + + Args: + flow_graph: the flow graph object + file_path: the path to write the file to """ self._flow_graph = flow_graph self._generate_options = self._flow_graph.get_option('generate_options') @@ -72,7 +74,9 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''') def get_popen(self): """ Execute this python flow graph. - @return a popen object + + Returns: + a popen object """ #extract the path to the python executable python_exe = sys.executable @@ -95,7 +99,9 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''') def __str__(self): """ Convert the flow graph to python code. - @return a string of python code + + Returns: + a string of python code """ title = self._flow_graph.get_option('title') or self._flow_graph.get_option('id').replace('_', ' ').title() imports = self._flow_graph.get_imports() diff --git a/grc/python/Param.py b/grc/python/Param.py index 2caca48024..b310468842 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -106,7 +106,9 @@ class Param(_Param, _GUIParam): def __repr__(self): """ Get the repr (nice string format) for this param. - @return the string representation + + Returns: + the string representation """ ################################################## # truncate helper method @@ -167,7 +169,9 @@ class Param(_Param, _GUIParam): def get_color(self): """ Get the color that represents this param's type. - @return a hex color code. + + Returns: + a hex color code. """ try: return { @@ -198,7 +202,9 @@ 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. - @return hide the hide property string + + Returns: + hide the hide property string """ hide = _Param.get_hide(self) if hide: return hide @@ -234,7 +240,9 @@ class Param(_Param, _GUIParam): def evaluate(self): """ Evaluate the value. - @return evaluated type + + Returns: + evaluated type """ self._init = True self._lisitify_flag = False @@ -435,7 +443,9 @@ 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. - @return a string representing the code + + Returns: + a string representing the code """ v = self.get_value() t = self.get_type() @@ -452,7 +462,11 @@ class Param(_Param, _GUIParam): def get_all_params(self, type): """ Get all the params from the flowgraph that have the given type. - @param type the specified type - @return a list of params + + Args: + type: the specified type + + Returns: + a list of params """ return sum([filter(lambda p: p.get_type() == type, block.get_params()) for block in self.get_parent().get_parent().get_enabled_blocks()], []) diff --git a/grc/python/Port.py b/grc/python/Port.py index 9f8b50d052..0e7051c7c0 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -84,9 +84,11 @@ class Port(_Port, _GUIPort): def __init__(self, block, n, dir): """ Make a new port from nested data. - @param block the parent element - @param n the nested odict - @param dir the direction + + Args: + block: the parent element + n: the nested odict + dir: the direction """ self._n = n if n['type'] == 'msg': n['key'] = 'msg' @@ -163,7 +165,9 @@ class Port(_Port, _GUIPort): """ Get the vector length. If the evaluation of vlen cannot be cast to an integer, return 1. - @return the vector length or 1 + + Returns: + the vector length or 1 """ vlen = self.get_parent().resolve_dependencies(self._vlen) try: return int(self.get_parent().get_parent().evaluate(vlen)) @@ -174,7 +178,9 @@ class Port(_Port, _GUIPort): Get the number of ports. If already blank, return a blank If the evaluation of nports cannot be cast to an integer, return 1. - @return the number of ports or 1 + + Returns: + the number of ports or 1 """ nports = self.get_parent().resolve_dependencies(self._nports) #return blank if nports is blank @@ -190,7 +196,9 @@ 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. - @return a hex color code. + + Returns: + a hex color code. """ try: color = Constants.TYPE_TO_COLOR[self.get_type()] diff --git a/grc/python/expr_utils.py b/grc/python/expr_utils.py index a2e56eedf9..67580f6ffc 100644 --- a/grc/python/expr_utils.py +++ b/grc/python/expr_utils.py @@ -54,8 +54,12 @@ 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. - @param expr an expression string - @return a list of string tokens that form expr + + Args: + expr: an expression string + + Returns: + a list of string tokens that form expr """ toks = list() tok = '' @@ -78,9 +82,13 @@ def expr_split(expr): def expr_replace(expr, replace_dict): """ Search for vars in the expression and add the prepend. - @param expr an expression string - @param replace_dict a dict of find:replace - @return a new expression with the prepend + + Args: + expr: an expression string + replace_dict: a dict of find:replace + + Returns: + a new expression with the prepend """ expr_splits = expr_split(expr) for i, es in enumerate(expr_splits): @@ -91,9 +99,13 @@ def expr_replace(expr, replace_dict): def get_variable_dependencies(expr, vars): """ Return a set of variables used in this expression. - @param expr an expression string - @param vars a list of variable names - @return a subset of vars used in the expression + + Args: + expr: an expression string + vars: a list of variable names + + Returns: + a subset of vars used in the expression """ expr_toks = expr_split(expr) return set(filter(lambda v: v in expr_toks, vars)) @@ -101,8 +113,12 @@ def get_variable_dependencies(expr, vars): def get_graph(exprs): """ Get a graph representing the variable dependencies - @param exprs a mapping of variable name to expression - @return a graph of variable deps + + Args: + exprs: a mapping of variable name to expression + + Returns: + a graph of variable deps """ vars = exprs.keys() #get dependencies for each expression, load into graph @@ -116,8 +132,12 @@ def get_graph(exprs): def sort_variables(exprs): """ Get a list of variables in order of dependencies. - @param exprs a mapping of variable name to expression - @return a list of variable names + + Args: + exprs: a mapping of variable name to expression + + Returns: + a list of variable names @throws Exception circular dependencies """ var_graph = get_graph(exprs) @@ -136,10 +156,14 @@ def sort_variables(exprs): def sort_objects(objects, get_id, get_expr): """ Sort a list of objects according to their expressions. - @param objects the list of objects to sort - @param get_id the function to extract an id from the object - @param get_expr the function to extract an expression from the object - @return a list of sorted objects + + 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 """ id2obj = dict([(get_id(obj), obj) for obj in objects]) #map obj id to expression code diff --git a/grc/python/extract_docs.py b/grc/python/extract_docs.py index a7e945c373..8c151b6e1a 100644 --- a/grc/python/extract_docs.py +++ b/grc/python/extract_docs.py @@ -23,8 +23,12 @@ def _extract(key): """ Extract the documentation from the python __doc__ strings. If multiple modules match, combine the docs. - @param key the block key - @return a string with documentation + + Args: + key: the block key + + Returns: + a string with documentation """ #extract matches try: @@ -48,8 +52,12 @@ _docs_cache = dict() def extract(key): """ Call the private extract and cache the result. - @param key the block key - @return a string with documentation + + Args: + key: the block key + + Returns: + a string with documentation """ if not _docs_cache.has_key(key): _docs_cache[key] = _extract(key) |