mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
Generate new config if current one is invalid
This commit is contained in:
parent
70fb85ba1f
commit
2db35f7dea
@ -1,9 +1,11 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Union
|
from typing import Union
|
||||||
from dacite import from_dict, Optional
|
from dacite import from_dict
|
||||||
import os.path
|
import os.path
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
# TODO Who even needs synchronization? (We do.)
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class RansacConfig:
|
class RansacConfig:
|
||||||
threshold: "int" = 0
|
threshold: "int" = 0
|
||||||
@ -20,7 +22,11 @@ class RansacConfig:
|
|||||||
print("No settings file, using base settings")
|
print("No settings file, using base settings")
|
||||||
return RansacConfig()
|
return RansacConfig()
|
||||||
with open("ransac_settings.json", 'r') as settings_file:
|
with open("ransac_settings.json", 'r') as settings_file:
|
||||||
|
try:
|
||||||
return from_dict(data_class = RansacConfig, data = json.load(settings_file))
|
return from_dict(data_class = RansacConfig, data = json.load(settings_file))
|
||||||
|
except:
|
||||||
|
print("Configuration invalid, creating new config")
|
||||||
|
return RansacConfig()
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
with open("ransac_settings.json", 'w+') as settings_file:
|
with open("ransac_settings.json", 'w+') as settings_file:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user