diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-08-06 11:54:31 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-08-06 11:54:31 +0000 |
commit | b7d566fc3ec60c0fbbca22af273bc67fdc1372fa (patch) | |
tree | 7e39f656c03db8daaee14bcd63e3722f2354ea45 /avahi-python | |
parent | d66af491a574de4d5421c995bec5357fc1c04128 (diff) |
Allow storing the service type database as Solaris DBM file, alternatively to gdbm. The latter is still recommended. (Patch from Padraig O'Briain)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1245 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-python')
-rw-r--r-- | avahi-python/avahi/Makefile.am | 17 | ||||
-rw-r--r-- | avahi-python/avahi/ServiceTypeDatabase.py.in | 10 |
2 files changed, 22 insertions, 5 deletions
diff --git a/avahi-python/avahi/Makefile.am b/avahi-python/avahi/Makefile.am index b1ebe22..5673d5e 100644 --- a/avahi-python/avahi/Makefile.am +++ b/avahi-python/avahi/Makefile.am @@ -25,10 +25,27 @@ avahidir = $(pythondir)/avahi avahi_SCRIPTS = ServiceTypeDatabase.py +if HAVE_GDBM ServiceTypeDatabase.py: ServiceTypeDatabase.py.in sed -e 's,@PYTHON\@,$(PYTHON),g' \ + -e 's,@DBM\@,gdbm,g' \ + -e 's,@FIRST_KEY\@,key = self.db.firstkey(),g' \ + -e 's,@CHECK_KEY\@,while key is not None:,g' \ + -e 's,@NEXT_KEY\@,key = self.db.nextkey(),g' \ -e 's,@pkgdatadir\@,$(pkgdatadir),g' $< > $@ chmod +x $@ +endif + +if HAVE_DBM +ServiceTypeDatabase.py: ServiceTypeDatabase.py.in + sed -e 's,@PYTHON\@,$(PYTHON),g' \ + -e 's,@DBM\@,dbm,g' \ + -e 's,@FIRST_KEY\@,keys = self.db.keys(),g' \ + -e 's,@CHECK_KEY\@,for key in keys:,g' \ + -e 's,@NEXT_KEY\@,,g' \ + -e 's,@pkgdatadir\@,$(pkgdatadir),g' $< > $@ + chmod +x $@ +endif if HAVE_PYGTK if HAVE_PYTHON_DBUS diff --git a/avahi-python/avahi/ServiceTypeDatabase.py.in b/avahi-python/avahi/ServiceTypeDatabase.py.in index 25807f3..95c03a4 100644 --- a/avahi-python/avahi/ServiceTypeDatabase.py.in +++ b/avahi-python/avahi/ServiceTypeDatabase.py.in @@ -19,7 +19,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. -import gdbm +import @DBM@ import locale import re @@ -29,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) @@ -69,12 +69,12 @@ class ServiceTypeDatabase: def items(self): items = [] - key = self.db.firstkey() - while key is not None: + @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)) - key = self.db.nextkey(key) + @NEXT_KEY@ return items def has_key(self, key): |