Use deepcopy for dict copy operations
The BASE content gets corrupted due to use of shallow copy in dictionary copy operations. Use copy.deepcopy instead. Change-Id: Ia29ccf1f60322c2de16309b7dd998ddf182917b4
This commit is contained in:
parent
cd089e90a5
commit
f8ce01d4e5
|
@ -15,6 +15,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import calendar
|
import calendar
|
||||||
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
import json
|
import json
|
||||||
|
@ -37,9 +38,9 @@ class PTGDataBase():
|
||||||
with open(self.filename, 'r') as fp:
|
with open(self.filename, 'r') as fp:
|
||||||
self.data = json.load(fp)
|
self.data = json.load(fp)
|
||||||
else:
|
else:
|
||||||
self.data = self.BASE
|
self.data = copy.deepcopy(self.BASE)
|
||||||
|
|
||||||
old_data = self.data['additional'].copy()
|
old_data = copy.deepcopy(self.data['additional'])
|
||||||
self.load_data_from_config()
|
self.load_data_from_config()
|
||||||
self.merge_additional(old_data)
|
self.merge_additional(old_data)
|
||||||
self.save()
|
self.save()
|
||||||
|
@ -167,7 +168,7 @@ class PTGDataBase():
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def wipe(self):
|
def wipe(self):
|
||||||
self.data = self.BASE
|
self.data = copy.deepcopy(self.BASE)
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
|
Loading…
Reference in New Issue