def _get_user_dirs(xdg_config_dir):
 dirs_file = os.path.join(xdg_config_dir, 'user-dirs.dirs')
 if (not os.path.exists(dirs_file)):
  return {}
 with open(dirs_file, u'rb') as fh:
  data = fh.read().decode(u'utf-8')
 data = (u'[XDG_USER_DIRS]\n' + data)
 data = data.replace(u'$HOME', os.path.expanduser(u'~'))
 data = data.replace(u'"', u'')
 config = configparser.RawConfigParser()
 config.readfp(io.StringIO(data))
 return {k.upper(): os.path.abspath(v) for (k, v) in config.items(u'XDG_USER_DIRS') if (v is not None)}

def _get_user_dirs ( xdg_config_dir ) : dirs_file = os . path . join ( xdg_config_dir , 'user-dirs.dirs' ) if ( not os . path . exists ( dirs_file ) ) : return { } with open ( dirs_file , u'rb' ) as fh : data = fh . read ( ) . decode ( u'utf-8' ) data = ( u'[XDG_USER_DIRS]\n' + data ) data = data . replace ( u'$HOME' , os . path . expanduser ( u'~' ) ) data = data . replace ( u'"' , u'' ) config = configparser . RawConfigParser ( ) config . readfp ( io . StringIO ( data ) ) return { k . upper ( ) : os . path . abspath ( v ) for ( k , v ) in config . items ( u'XDG_USER_DIRS' ) if ( v is not None ) }
returns a dict of xdg dirs read from $xdg_config_home/user-dirs .