source: geniuswebcore/geniusweb/profileconnection/FileProfileConnector.py

Last change on this file was 100, checked in by ruud, 20 months ago

python installs also wheel to avoid error messages

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.