]> git.meshlink.io Git - catta/blobdiff - avahi-python/avahi/ServiceTypeDatabase.py.in
get rid of a lot of old svn cruft
[catta] / avahi-python / avahi / ServiceTypeDatabase.py.in
index 9caeebd91cd74ca9cdd17743a6c306baa862c8a0..8a77a31b28bfcd78bbc816d27cd747315a6d26fb 100644 (file)
@@ -1,7 +1,5 @@
 #!@PYTHON@
 # -*-python-*-
-# $Id$
-
 # This file is part of avahi.
 #
 # avahi is free software; you can redistribute it and/or modify it
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
-import gdbm
+import @DBM@
 import locale
+import re
 
 locale.setlocale(locale.LC_ALL, '')
 
 class ServiceTypeDatabase:
 
-    def __init__(self, filename = "@pkgdatadir@/service-types.db"):
+    def __init__(self, filename = "@pkglibdir@/service-types.db"):
 
-        self.db = gdbm.open(filename, "r")
+        self.db = @DBM@.open(filename, "r")
 
         l = locale.getlocale(locale.LC_MESSAGES)
 
@@ -65,6 +64,17 @@ class ServiceTypeDatabase:
 
         raise KeyError()
 
+    def items(self):
+
+        items = []
+        @FIRST_KEY@
+        @CHECK_KEY@
+            if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key) and not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key):
+                localized_service_name = self[key]
+                items.append((key, localized_service_name))
+            @NEXT_KEY@
+        return items
+
     def has_key(self, key):
 
         for suffix in self.suffixes:
@@ -88,6 +98,7 @@ class ServiceTypeDatabase:
 if __name__ == "__main__":
     
     b = ServiceTypeDatabase()
+    print b.items()
 
     print b["_http._tcp"]
     print b["_ftp._tcp"]