projects
/
osm
/
common.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
new utility deep_update following rfc7396 plus array edition
[osm/common.git]
/
osm_common
/
dbmemory.py
diff --git
a/osm_common/dbmemory.py
b/osm_common/dbmemory.py
index
c27f846
..
63c93c1
100644
(file)
--- a/
osm_common/dbmemory.py
+++ b/
osm_common/dbmemory.py
@@
-33,10
+33,10
@@
class DbMemory(DbBase):
def get_list(self, table, filter={}):
try:
def get_list(self, table, filter={}):
try:
-
l
= []
+
result
= []
for _, row in self._find(table, self._format_filter(filter)):
for _, row in self._find(table, self._format_filter(filter)):
-
l
.append(deepcopy(row))
- return
l
+
result
.append(deepcopy(row))
+ return
result
except DbException:
raise
except Exception as e: # TODO refine
except DbException:
raise
except Exception as e: # TODO refine
@@
-44,17
+44,17
@@
class DbMemory(DbBase):
def get_one(self, table, filter={}, fail_on_empty=True, fail_on_more=True):
try:
def get_one(self, table, filter={}, fail_on_empty=True, fail_on_more=True):
try:
-
l
= None
+
result
= None
for _, row in self._find(table, self._format_filter(filter)):
if not fail_on_more:
return deepcopy(row)
for _, row in self._find(table, self._format_filter(filter)):
if not fail_on_more:
return deepcopy(row)
- if
l
:
+ if
result
:
raise DbException("Found more than one entry with filter='{}'".format(filter),
HTTPStatus.CONFLICT.value)
raise DbException("Found more than one entry with filter='{}'".format(filter),
HTTPStatus.CONFLICT.value)
-
l
= row
- if not
l
and fail_on_empty:
+
result
= row
+ if not
result
and fail_on_empty:
raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND)
raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND)
- return deepcopy(
l
)
+ return deepcopy(
result
)
except Exception as e: # TODO refine
raise DbException(str(e))
except Exception as e: # TODO refine
raise DbException(str(e))
@@
-64,7
+64,7
@@
class DbMemory(DbBase):
for i, _ in self._find(table, self._format_filter(filter)):
id_list.append(i)
deleted = len(id_list)
for i, _ in self._find(table, self._format_filter(filter)):
id_list.append(i)
deleted = len(id_list)
- for i in
id_list
:
+ for i in
reversed(id_list)
:
del self.db[table][i]
return {"deleted": deleted}
except DbException:
del self.db[table][i]
return {"deleted": deleted}
except DbException:
@@
-94,7
+94,7
@@
class DbMemory(DbBase):
raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND)
return None
self.db[table][i] = deepcopy(indata)
raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND)
return None
self.db[table][i] = deepcopy(indata)
- return {"up
ad
ted": 1}
+ return {"up
da
ted": 1}
except Exception as e: # TODO refine
raise DbException(str(e))
except Exception as e: # TODO refine
raise DbException(str(e))