source: geniuswebcore/geniusweb/profileconnection/FileProfileConnector.py@ 99

Last change on this file since 99 was 96, checked in by Bart Vastenhouw, 2 years ago

Fixed small issues in domaineditor.

File size: 868 bytes
Line 
1import json
2from pathlib import Path
3
4from pyson.ObjectMapper import ObjectMapper
5from tudelft.utilities.listener.DefaultListenable import DefaultListenable
6
7from geniusweb.profile.Profile import Profile
8from geniusweb.profileconnection.ProfileInterface import ProfileInterface
9
10
11class FileProfileConnector (DefaultListenable[Profile], ProfileInterface):
12 '''
13 ProfileInterface based on a plain filesystem UTF8 file.
14 '''
15 _pyson = ObjectMapper()
16
17 def __init__(self, filename:str) :
18 '''
19 @param filename the filename of the file containing the profile
20 @throws IOException if the profile is not proper json
21 '''
22 serialized = Path(filename).read_text("utf-8")
23 self._profile:Profile = self._pyson.parse(json.loads(serialized), Profile) #type:ignore
24
25 #Override
26 def getProfile(self) ->Profile :
27 return self._profile
28
29 #Override
30 def close(self) :
31 pass
Note: See TracBrowser for help on using the repository browser.