LogoSearch packages:      

Sourcecode: screenlets version File versions  Download package

def lib::utils::IniReader::load (   self,
  filename 
)

Load a config/ini-file and save vars in internal list.

Definition at line 193 of file utils.py.

00193                                :
            """Load a config/ini-file and save vars in internal list."""
            f=None
            try:
                  f = open (filename, "r")
            except:
                  print "File " + str(filename) + " not found"
            if f:
                  section_name = ''
                  for line in f.readlines():
                        # strip whitespace/tabs on the left
                        line = line.lstrip().lstrip('\t')
                        #print line
                        # ignore comment, EOL and too short lines
                        if len(line) < 4 or line[0] in ("#", "\n", ";"):
                              pass
                        else:
                              # split var/value and trim
                              tmp = line.split('=', 1)
                              # no '=' found? check for section name
                              if len(tmp) < 2 and len(line) > 5 and line[0] == '[':
                                    section_name = line[:-1][1:-1]
                                    self.sections[section_name] =  []
                                    #print "Section found: %s" % section_name
                              else:
                                    # two entries? split var/value
                                    var = tmp[0].rstrip().rstrip('\t')
                                    val = tmp[1][:-1].lstrip()    # remove EOL
                                    #print "VAR: %s=%s" % (var, val)
                                    # and add them to lists
                                    if var != '' and val != '':
                                          o = [var, val]
                                          self.options.append(o)
                                          if section_name != '':
                                                try:
                                                      self.sections[section_name].append(o)
                                                except:
                                                      print _("Section %s not found!") % section_name
                  f.close()
                  return True
            else:
                  return False

class Notifier:


Generated by  Doxygen 1.5.1   Back to index