diff options
author | Justin Santa Barbara <justin@fathomdb.com> | 2011-02-23 14:07:08 -0800 |
---|---|---|
committer | Justin Santa Barbara <justin@fathomdb.com> | 2011-02-23 14:07:08 -0800 |
commit | 1183c9e11b12984b1f5007ace831864e80483712 (patch) | |
tree | f1f02850f928ef03a5c44d7e7655f1d1b5ee6c53 /nova/utils.py | |
parent | 89ade95d2eaabf77f9c81a8d50c7cc11aa175464 (diff) | |
download | nova-1183c9e11b12984b1f5007ace831864e80483712.tar.gz nova-1183c9e11b12984b1f5007ace831864e80483712.tar.xz nova-1183c9e11b12984b1f5007ace831864e80483712.zip |
Rename minixpath_select to get_from_path
Diffstat (limited to 'nova/utils.py')
-rw-r--r-- | nova/utils.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/nova/utils.py b/nova/utils.py index c2cbeb2a7..65e28c648 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -32,10 +32,10 @@ import string import struct import sys import time +import types from xml.sax import saxutils import re import netaddr -import types from eventlet import event from eventlet import greenthread @@ -503,18 +503,19 @@ def ensure_b64_encoding(val): return base64.b64encode(val) -def minixpath_select(items, minixpath): - """ Takes an xpath-like expression e.g. prop1/prop2/prop3, and for each - item in items, looks up items[prop1][prop2][prop3]. Like XPath, if any of - the intermediate results are lists it will treat each list item - individually. A 'None' in items or any child expressions will be ignored, - this function will not throw because of None (anywhere) in items. The - returned list will contain no None values.""" +def get_from_path(items, path): + """ Returns a list of items matching the specified path. Takes an + XPath-like expression e.g. prop1/prop2/prop3, and for each item in items, + looks up items[prop1][prop2][prop3]. Like XPath, if any of the + intermediate results are lists it will treat each list item individually. + A 'None' in items or any child expressions will be ignored, this function + will not throw because of None (anywhere) in items. The returned list + will contain no None values.""" - if minixpath is None: + if path is None: raise exception.Error("Invalid mini_xpath") - (first_token, sep, remainder) = minixpath.partition("/") + (first_token, sep, remainder) = path.partition("/") if first_token == "": raise exception.Error("Invalid mini_xpath") @@ -537,7 +538,6 @@ def minixpath_select(items, minixpath): child = get_method(first_token) if child is None: continue - #print "%s => %s" % (first_token, child) if isinstance(child, types.ListType): # Flatten intermediate lists for x in child: @@ -549,4 +549,4 @@ def minixpath_select(items, minixpath): # No more tokens return results else: - return minixpath_select(results, remainder) + return get_from_path(results, remainder) |