def testConfigReadPath(self): app = xdg.APPLICATION # no such config file exists self.assertIdentical(xdg.config_read_path('test'), None) # create a config file in the first XDG config dir path = os.path.join(self.xdg_config_dir1, app, 'test') file(path, 'w').close() # should now be found self.assertEquals(xdg.config_read_path('test'), path) # create a config file in the second XDG config dir, should not change # the order path2 = os.path.join(self.xdg_config_dir2, app, 'test') file(path2, 'w').close() self.assertEquals(xdg.config_read_path('test'), path) # remove the file from the first XDG config dir, the second one should # be found os.remove(path) self.assertEquals(xdg.config_read_path('test'), path2) # create a config file in the XDG home dir, should come first path_home = os.path.join(self.xdg_config_home, app, 'test') file(path_home, 'w').close() self.assertEquals(xdg.config_read_path('test'), path_home) # chmod that file 000, should be skipped old_perms = os.stat(path_home).st_mode os.chmod(path_home, 0000) self.assertEquals(xdg.config_read_path('test'), path2) os.chmod(path_home, old_perms)
def getDefaultConnections(): """ Fetches a list of default connections. @returns: default connections @rtype: list of L{ConnectionInfo} """ filename = xdg.config_read_path('connections') if not filename: return [] try: return _parseMultipleConnectionsFile(filename) except Exception, e: log.warning('connections', 'Error parsing %s: %r', filename, e)