diff options
author | Stanislav Ochotnicky <sochotnicky@gmail.com> | 2009-06-11 23:03:51 +0200 |
---|---|---|
committer | Stanislav Ochotnicky <sochotnicky@gmail.com> | 2009-06-11 23:03:51 +0200 |
commit | 7f740a9803cb1f7572a91bf7d28e92f71387cf34 (patch) | |
tree | 86d112f82582079f8660e246cc7be30654921fb5 /util | |
parent | Added doc model for collagen (diff) | |
download | collagen-7f740a9803cb1f7572a91bf7d28e92f71387cf34.tar.gz collagen-7f740a9803cb1f7572a91bf7d28e92f71387cf34.tar.bz2 collagen-7f740a9803cb1f7572a91bf7d28e92f71387cf34.zip |
Added function to flatten nested dep list
Diffstat (limited to 'util')
-rw-r--r-- | util/__init__.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/util/__init__.py b/util/__init__.py index c0d7b5a..e57d4f4 100644 --- a/util/__init__.py +++ b/util/__init__.py @@ -19,3 +19,20 @@ class WritableObject: for part in self.content: ret = ret + part return ret + +def flatten_deps(deps): + """ + Takes nested deps returned from portage.dep.use_reduce and flattens them to simple list + + @param deps: list of dependencies returned from portage.dep.use_reduce() + @type deps: List + @rtype: List + @return: Flattened list of deps + """ + result = [] + for el in deps: + if hasattr(el, "__iter__") and not isinstance(el, basestring): + result.extend(flatten_deps(el)) + else: + result.append(el) + return result |