X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-python%2Favahi%2FServiceTypeDatabase.py.in;h=95c03a47cff097181000947feb966b3972599db6;hb=0cbaf99fc5eea82006dbc07f6c561e5d6d9cefba;hp=9caeebd91cd74ca9cdd17743a6c306baa862c8a0;hpb=ced0d86acf70f435ffdadb794db891be63a5b82a;p=catta diff --git a/avahi-python/avahi/ServiceTypeDatabase.py.in b/avahi-python/avahi/ServiceTypeDatabase.py.in index 9caeebd..95c03a4 100644 --- a/avahi-python/avahi/ServiceTypeDatabase.py.in +++ b/avahi-python/avahi/ServiceTypeDatabase.py.in @@ -19,8 +19,9 @@ # 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, '') @@ -28,7 +29,7 @@ class ServiceTypeDatabase: def __init__(self, filename = "@pkgdatadir@/service-types.db"): - self.db = gdbm.open(filename, "r") + self.db = @DBM@.open(filename, "r") l = locale.getlocale(locale.LC_MESSAGES) @@ -65,6 +66,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 +100,7 @@ class ServiceTypeDatabase: if __name__ == "__main__": b = ServiceTypeDatabase() + print b.items() print b["_http._tcp"] print b["_ftp._tcp"]