[sysadmin-bin: 124/168] semi_rdf.py: Add find_properties to Node class



commit 7467729a0b1b8d7f8c65f4df5488e472d1b9ba96
Author: Olav Vitters <olav bkor dhs org>
Date:   Thu Jul 30 09:33:58 2009 +0200

    semi_rdf.py: Add find_properties to Node class

 semi_rdf.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/semi_rdf.py b/semi_rdf.py
index d294b3e..3db9dc1 100755
--- a/semi_rdf.py
+++ b/semi_rdf.py
@@ -50,6 +50,15 @@ class Node:
 
         return value
 
+    def find_properties(self, name, lang="en"):
+        value = None
+        for (n, l, v) in self.properties:
+            if n == name:
+                if l == lang:
+                    yield v
+                elif l == None or value == None:
+                    yield v
+
     def add_property(self, name, lang, value):
         self.properties.append((name, lang, value))
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]