2828translation of the old data format (as seen in the file) to the current format
2929(as required by UserData and thus Main).
3030
31- If a new version changes the UserData layout, *ALL* previous loaders have to be
32- updated to return this new layout. Therefore it is best not to modify the order
33- and names of UserData arguments.
31+ If a new version changes the UserData layout, the DataManager.save method must
32+ be updated to reflect that. Additionally, all previously registered loaders
33+ must be able to return the new object. When adding a new element to UserData,
34+ it should go without problems (just provide a default argument), but if a new
35+ layout removes some fields... this will need special handling - probably for
36+ *all* legacy loaders.
3437"""
3538
3639import os
@@ -49,6 +52,7 @@ def __init__(
4952 series_data = '' ,
5053 games_conf = '' ,
5154 games_data = '' ,
55+ options_json = '{}' ,
5256 is_empty = True
5357 ):
5458 self .username = username
@@ -58,6 +62,7 @@ def __init__(
5862 self .series_data = series_data
5963 self .games_conf = games_conf
6064 self .games_data = games_data
65+ self .options_json = options_json
6166 self .is_empty = is_empty
6267
6368
@@ -97,6 +102,8 @@ def save(self, userData):
97102 user_file .write (self .version + '\n ' )
98103 user_file .write ('#USERNAME\n ' )
99104 user_file .write (userData .username + '\n ' )
105+ user_file .write ('#OPTIONS\n ' )
106+ user_file .write (userData .options_json + '\n ' )
100107 user_file .write ('#MOVIES\n ' )
101108 user_file .write (userData .movies_conf + '\n ' )
102109 user_file .write (userData .movies_data + '\n ' )
@@ -212,3 +219,16 @@ def loader100b(user_data):
212219 games_conf = user_data [6 ],
213220 games_data = user_data [7 ]
214221 )
222+
223+ @DataManager .registerLoaderSince ('1.0.0-beta.4' )
224+ def loader100b4 (user_data ):
225+ return UserData (
226+ username = user_data [1 ],
227+ options_json = user_data [2 ],
228+ movies_conf = user_data [3 ],
229+ movies_data = user_data [4 ],
230+ series_conf = user_data [5 ],
231+ series_data = user_data [6 ],
232+ games_conf = user_data [7 ],
233+ games_data = user_data [8 ],
234+ )
0 commit comments