Use intermediate filename when converting.
[recordtv.git] / src / rtv_propertiesfile.py
blob544d084448979bac916588a34d77151ae59dc1dd
1 #!/usr/bin/python
3 import os
5 from rtv_abstractpropertiesfile import AbstractPropertiesFile
7 class PropertiesFile( AbstractPropertiesFile ):
9 def set_value( self, key, value ):
10 self.__dict__[key] = value
12 def get_value( self, key ):
13 ret = None
14 if key in self.__dict__:
15 ret = self.__dict__[key]
16 return ret
18 def get_keys( self ):
19 return self.__dict__.keys()
21 def test():
22 # Testing code:
24 pf = PropertiesFile()
25 pf.mystr = "Hello2"
26 pf.mystrpipe = "|Hello"
27 pf.mytuple = ( "x", "y", "z" )
28 pf.mylist = [ "xa", "yb", "zc" ]
29 pf.myint = 45
30 pf.myfloat = 5.8
31 pf.mybool = False
32 pf.mystrbool = "False"
34 filename = "tmp.rtvtestpropertiesfile"
36 pf.save( filename )
38 pf2 = PropertiesFile()
39 pf2.load( filename )
41 os.unlink( filename )
43 # Convert pf's tuple value to a list before comparison -
44 # we convert every sequence type to a list
45 pf.mytuple = list( pf.mytuple )
47 assert( pf.__dict__ == pf2.__dict__ )
49 # TODO: test reading a file with spaces around the =, etc.