From aa3ab32680874ca4cb89b07be2793aab07cefcfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Thu, 9 Jun 2005 09:36:41 +0000 Subject: [PATCH] =?UTF-8?q?=C3=A7o=C4=9Fu=20durumda=20kullanaca=C4=9F?= =?UTF-8?q?=C4=B1m=C4=B1z=20yaln=C4=B1zca=20ilk=20eri=C5=9Filen=20node'un?= =?UTF-8?q?=20metinini=20=C3=A7ekmek=20i=C3=A7in=20bir=20fonksiyon=20eklen?= =?UTF-8?q?di.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/specfile.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/specfile.py b/src/specfile.py index 792acecd..e6905f1c 100644 --- a/src/specfile.py +++ b/src/specfile.py @@ -24,8 +24,25 @@ from a PSPEC file""" return nodelist - def getText(self, nodepath): - pass + def getFirstNode(self, nodepath): + try: + return self.getNodes(nodepath)[0] + except IndexError: + return None + + def getFirstChildText(self, nodepath): + node = self.getFirstNode(nodepath) + if not node: + return None + + # get the first child + try: + child = node.childNodes[0] + except IndexError: + return None + + if child.nodeType == child.TEXT_NODE: + return child.data def getAttribute(self, nodepath, attribute): pass