Browse Source

Merge pull request #4492 from SomberNight/config_v3_baseunits

follow-up re #4491, do config upgrade to keep base unit settings on kivy
3.2.x
ThomasV 7 years ago
committed by GitHub
parent
commit
0ad013f144
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      lib/simple_config.py

16
lib/simple_config.py

@ -37,7 +37,7 @@ def set_config(c):
config = c config = c
FINAL_CONFIG_VERSION = 2 FINAL_CONFIG_VERSION = 3
class SimpleConfig(PrintError): class SimpleConfig(PrintError):
@ -164,6 +164,7 @@ class SimpleConfig(PrintError):
self.print_error('upgrading config') self.print_error('upgrading config')
self.convert_version_2() self.convert_version_2()
self.convert_version_3()
self.set_key('config_version', FINAL_CONFIG_VERSION, save=True) self.set_key('config_version', FINAL_CONFIG_VERSION, save=True)
@ -186,6 +187,19 @@ class SimpleConfig(PrintError):
self.set_key('config_version', 2) self.set_key('config_version', 2)
def convert_version_3(self):
if not self._is_upgrade_method_needed(2, 2):
return
base_unit = self.user_config.get('base_unit')
if isinstance(base_unit, str):
self._set_key_in_user_config('base_unit', None)
map_ = {'btc':8, 'mbtc':5, 'ubtc':2, 'bits':2, 'sat':0}
decimal_point = map_.get(base_unit.lower())
self._set_key_in_user_config('decimal_point', decimal_point)
self.set_key('config_version', 3)
def _is_upgrade_method_needed(self, min_version, max_version): def _is_upgrade_method_needed(self, min_version, max_version):
cur_version = self.get_config_version() cur_version = self.get_config_version()
if cur_version > max_version: if cur_version > max_version:

Loading…
Cancel
Save