def get_default_ddir():
 user_home = os.path.expanduser('~')
 (join, exists) = (os.path.join, os.path.exists)
 if mswin:
  return join(user_home, 'Downloads', 'mps')
 USER_DIRS = join(user_home, '.config', 'user-dirs.dirs')
 DOWNLOAD_HOME = join(user_home, 'Downloads')
 if ('XDG_DOWNLOAD_DIR' in os.environ):
  ddir = os.environ['XDG_DOWNLOAD_DIR']
 elif exists(USER_DIRS):
  lines = open(USER_DIRS).readlines()
  defn = [x for x in lines if x.startswith('XDG_DOWNLOAD_DIR')]
  if (len(defn) == 1):
   ddir = defn[0].split('=')[1].replace('"', '')
   ddir = ddir.replace('$HOME', user_home).strip()
  else:
   ddir = (DOWNLOAD_HOME if exists(DOWNLOAD_HOME) else user_home)
 else:
  ddir = (DOWNLOAD_HOME if exists(DOWNLOAD_HOME) else user_home)
 ddir = ddir
 return os.path.join(ddir, 'mps')

def get_default_ddir ( ) : user_home = os . path . expanduser ( '~' ) ( join , exists ) = ( os . path . join , os . path . exists ) if mswin : return join ( user_home , 'Downloads' , 'mps' ) USER_DIRS = join ( user_home , '.config' , 'user-dirs.dirs' ) DOWNLOAD_HOME = join ( user_home , 'Downloads' ) if ( 'XDG_DOWNLOAD_DIR' in os . environ ) : ddir = os . environ [ 'XDG_DOWNLOAD_DIR' ] elif exists ( USER_DIRS ) : lines = open ( USER_DIRS ) . readlines ( ) defn = [ x for x in lines if x . startswith ( 'XDG_DOWNLOAD_DIR' ) ] if ( len ( defn ) == 1 ) : ddir = defn [ 0 ] . split ( '=' ) [ 1 ] . replace ( '"' , '' ) ddir = ddir . replace ( '$HOME' , user_home ) . strip ( ) else : ddir = ( DOWNLOAD_HOME if exists ( DOWNLOAD_HOME ) else user_home ) else : ddir = ( DOWNLOAD_HOME if exists ( DOWNLOAD_HOME ) else user_home ) ddir = ddir return os . path . join ( ddir , 'mps' )
get system default download directory .