From 994d0293da811d443f2803bc49c14568835de3f1 Mon Sep 17 00:00:00 2001 From: Kristofer Hallin Date: Wed, 6 Oct 2021 11:22:59 +0200 Subject: Minor cleanups. --- src/db.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/db.py b/src/db.py index 1f35cac..14a435d 100755 --- a/src/db.py +++ b/src/db.py @@ -1,5 +1,3 @@ -#! /usr/bin/env python3 - # A database storing dictionaries, keyed on a timestamp. # value = A dict which will be stored as a JSON object encoded in # UTF-8. Note that dict keys of type integer or float will become @@ -33,7 +31,7 @@ class DictDB(): } self.couchdb = self.server.create(database) - print(self.couchdb.index(index)) + self.couchdb.index(index) self._ts = time.time() @@ -53,7 +51,7 @@ class DictDB(): self.couchdb.save(item) else: - data['_id']=key + data['_id'] = key self.couchdb.save(data) return key @@ -65,19 +63,19 @@ class DictDB(): pass def search(self, **kwargs): - data=list() - selector=dict() + data = list() + selector = dict() if kwargs: - selector={ + selector = { "selector": { } } for key in kwargs: if kwargs[key].isnumeric(): - kwargs[key]=int(kwargs[key]) - selector['selector'][key]={'$eq': kwargs[key]} + kwargs[key] = int(kwargs[key]) + selector['selector'][key] = {'$eq': kwargs[key]} for doc in self.couchdb.find(selector): data.append(doc) -- cgit v1.1