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

Last change on this file since 62 was 59, checked in by Wouter Pasman, 3 years ago

#44 manual commit of first public release, because this will cause the dist directory to move

File size: 855 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)
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.