update to new MutableMapping import path

collections.MutableMapping is deprecated since version Python 3.3
and was removed in Python 3.10
master
vuko 2022-10-04 22:00:58 +02:00
parent 8bff421cc4
commit 987705b436
1 changed files with 3 additions and 4 deletions

View File

@ -1,5 +1,5 @@
from sys import stderr
from collections import MutableMapping
from collections.abc import MutableMapping
from io import StringIO
import csv, json
@ -12,7 +12,7 @@ class Storage(MutableMapping):
def sync(self):
self.encapsulation.data = self.encode(self.data)
self.encapsulation.end_transaction()
self.encapsulation.begin_transaction()
def __setitem__(self, k, v):
self.data[k] = v
@ -30,7 +30,7 @@ class Storage(MutableMapping):
class CsvStorage(Storage):
def decode(self, text):
try:
stored = {x[0]: [x[1], x[2]]
stored = {x[0]: [x[1], x[2]]
for x in csv.reader(StringIO(text))}
except IOError as e:
print(e, file=stderr)
@ -52,4 +52,3 @@ class JsonStorage(Storage):
return stored
def encode(self, data):
return json.dumps(data, indent=4)