diff options
Diffstat (limited to 'lib/sexp')
| -rw-r--r-- | lib/sexp/access.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sexp/access.py b/lib/sexp/access.py index beb87c9..c5182f0 100644 --- a/lib/sexp/access.py +++ b/lib/sexp/access.py @@ -36,6 +36,16 @@ def s_child(s, tag): return child return None +def s_attr(s, tag): + """Returns the second element of the child of 's' whose tag is 'tag'. + This is helpful for extracting a (key val) element. Returns None + if there is no such element. + """ + ch = s_child(s,tag) + if ch == None or len(ch) < 2: + return None + return ch[1] + def s_children(s, tag): """Returns a generator yielding all children of 's' whose tag is 'tag'. |
