/usr/share/pyshared/kdj/options.py is in libkate-tools 0.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | import os
class Options:
def __init__(self,path):
self.rc=os.path.join(path,'.KateDJrc')
#print 'options: config file is '+self.rc
try:
self.SetDefaults()
self.Load()
except:
pass
def SetDefaults(self):
self.save_as_copy=True
self.remove_temporary_files=False
self.format='kate'
def Load(self):
f=open(self.rc,'Ur')
if not f:
return
try:
try:
line=f.readline()
while line:
line=self.Frob(line)
self.Parse(line)
line=f.readline()
except:
pass
finally:
f.close()
def Save(self):
f=open(self.rc,'w')
f.write('save_as_copy='+self.Bool2String(self.save_as_copy)+'\n')
f.write('remove_temporary_files='+self.Bool2String(self.remove_temporary_files)+'\n')
f.write('format='+self.format.lower()+'\n')
f.close()
def Bool2String(self,val):
if val:
return 'true'
else:
return 'false'
def String2Bool(self,val):
val=val.lower()
if val=='true' or val=='1' or val=='yes' or val=='y':
return True
else:
return False
def String2Format(self,val):
val=val.lower()
if val=='kate':
return 'kate'
if val=='srt':
return 'srt'
if val=='lrc':
return 'lrc'
return 'kate'
def Frob(self,line):
line=line.split('#')[0]
line=line.split('\n')[0]
return line
def Parse(self,line):
var,val=line.split('=')[0:2]
if var.lower()=='save_as_copy': self.save_as_copy=self.String2Bool(val)
elif var.lower()=='remove_temporary_files': self.remove_temporary_files=self.String2Bool(val)
elif var.lower()=='format': self.format=self.String2Format(val)
#else: print 'unknown variable: '+line
|