if config does not exist do not print error could not open file

This commit is contained in:
Nikos Kouremenos 2005-05-06 08:33:23 +00:00
parent a346454c45
commit 61d6692a8d
2 changed files with 9 additions and 8 deletions

View file

@ -3,6 +3,7 @@
## Gajim Team: ## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org> ## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org> ## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <kourem@gmail.com>
## ##
## Copyright (C) 2003-2005 Gajim Team ## Copyright (C) 2003-2005 Gajim Team
## ##
@ -24,7 +25,7 @@ class OptionsParser:
self.__filename = os.path.expanduser(filename) self.__filename = os.path.expanduser(filename)
def read_line(self, line): def read_line(self, line):
index = line.find(" = ") index = line.find(' = ')
var_str = line[0:index] var_str = line[0:index]
value_str = line[index + 3:-1] value_str = line[index + 3:-1]
@ -44,7 +45,8 @@ class OptionsParser:
try: try:
fd = open(self.__filename) fd = open(self.__filename)
except: except:
print "error: cannot open %s for reading\n" % (self.__filename) if os.path.exists(self.__filename):
print 'error: cannot open %s for reading\n' % (self.__filename)
return return
for line in fd.readlines(): for line in fd.readlines():
@ -53,12 +55,12 @@ class OptionsParser:
fd.close() fd.close()
def write_line(self, fd, opt, parents, value): def write_line(self, fd, opt, parents, value):
s = "" s = ''
if parents: if parents:
if len(parents) == 1: if len(parents) == 1:
return return
for p in parents: for p in parents:
s += p + "." s += p + '.'
if value == None: if value == None:
return return
s += opt s += opt
@ -68,7 +70,7 @@ class OptionsParser:
try: try:
fd = open(self.__filename, 'w') fd = open(self.__filename, 'w')
except: except:
print "error: cannot open %s for writing\n" % (self.__filename) print 'error: cannot open %s for writing\n' % (self.__filename)
return return
gajim.config.foreach(self.write_line, fd) gajim.config.foreach(self.write_line, fd)
fd.close() fd.close()

View file

@ -7110,10 +7110,9 @@ Custom</property>
<child> <child>
<widget class="GtkHButtonBox" id="information_hbuttonbox"> <widget class="GtkHButtonBox" id="information_hbuttonbox">
<property name="border_width">5</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property> <property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">15</property> <property name="spacing">10</property>
<child> <child>
<widget class="GtkButton" id="close_button"> <widget class="GtkButton" id="close_button">
@ -7130,7 +7129,7 @@ Custom</property>
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">5</property>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
</packing> </packing>