~ubuntu-branches/ubuntu/trusty/gnuradio/trusty-updates

« back to all changes in this revision

Viewing changes to grc/python/expr_utils.py

  • Committer: Package Import Robot
  • Author(s): A. Maitland Bottoms
  • Date: 2012-02-26 21:26:16 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120226212616-vsfkbi1158xshdql
Tags: 3.5.1-1
* new upstream version, re-packaged from scratch with modern tools
    closes: #642716, #645332, #394849, #616832, #590048, #642580,
    #647018, #557050, #559640, #631863
* CMake build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""
2
 
Copyright 2008, 2009 Free Software Foundation, Inc.
 
2
Copyright 2008-2011 Free Software Foundation, Inc.
3
3
This file is part of GNU Radio
4
4
 
5
5
GNU Radio Companion is free software; you can redistribute it and/or
118
118
        Get a list of variables in order of dependencies.
119
119
        @param exprs a mapping of variable name to expression
120
120
        @return a list of variable names
121
 
        @throws AssertionError circular dependencies
 
121
        @throws Exception circular dependencies
122
122
        """
123
123
        var_graph = get_graph(exprs)
124
124
        sorted_vars = list()
126
126
        while var_graph.get_nodes():
127
127
                #get a list of nodes with no edges
128
128
                indep_vars = filter(lambda var: not var_graph.get_edges(var), var_graph.get_nodes())
129
 
                assert indep_vars
 
129
                if not indep_vars: raise Exception('circular dependency caught in sort_variables')
130
130
                #add the indep vars to the end of the list
131
131
                sorted_vars.extend(sorted(indep_vars))
132
132
                #remove each edge-less node from the graph