From ddc03061218dc00a664aaf10a6a2fec2b604deac Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 16 Sep 2008 16:07:40 +0000 Subject: More glider hacks: implement public keys. git-svn-id: file:///home/or/svnrepo/updater/trunk@16917 55e972cd-5a19-0410-ae62-a4d7a52db4cd --- lib/sexp/access.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/sexp/access.py') 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'. -- cgit v1.2.3