parameters: (filename)
return_statement: return cfgdict
docstring: Convert content of config-file into dictionary.
docstring_summary: Convert content of config-file into dictionary.
docstring_tokens: Convert content of config - file into dictionary .
function: def config_dict(filename):
      """Convert content of config-file into dictionary."""
      with open(filename, "r") as f:
          cfglines = f.readlines()
      cfgdict = {}
      for line in cfglines:
          line = line.strip()
          if not line or line.startswith("#"):
              continue
          try:
              key, value = line.split("=")
          except ValueError:
              print("Bad line in config-file %s:\n%s" % (filename,line))
              continue
          key = key.strip()
          value = value.strip()
          if value in ["True", "False", "None", "''", '""']:
              value = eval(value)
          else:
              try:
                  if "." in value:
                      value = float(value)
                  else:
                      value = int(value)
              except ValueError:
                  pass # value need not be converted
          cfgdict[key] = value
      return cfgdict
function_tokens: def config_dict ( filename ) : with open ( filename , "r" ) as f : cfglines = f . readlines ( ) cfgdict = { } for line in cfglines : line = line . strip ( ) if not line or line . startswith ( "#" ) : continue try : key , value = line . split ( "=" ) except ValueError : print ( "Bad line in config-file %s:\n%s" % ( filename , line ) ) continue key = key . strip ( ) value = value . strip ( ) if value in [ "True" , "False" , "None" , "''" , '""' ] : value = eval ( value ) else : try : if "." in value : value = float ( value ) else : value = int ( value ) except ValueError : pass # value need not be converted cfgdict [ key ] = value return cfgdict