Changeset 83283c


Ignore:
Timestamp:
05/27/2011 10:45:54 PM (14 years ago)
Author:
Calum Lind <calumlind+deluge@gmail.com>
Children:
da6793
Parents:
14c3655
git-author:
Calum Lind <calumlind+deluge@gmail.com> (05/26/2011 12:11:09 AM)
git-committer:
Calum Lind <calumlind+deluge@gmail.com> (05/27/2011 10:45:54 PM)
Message:

Add XDG_DOWNLOAD_DIR for default download folder #1788

File:
1 edited

Legend:

Unmodified
Added
Removed
  • deluge/common.py

    r14c3655 r83283c  
    166166        return os.path.expanduser("~")
    167167    else:
     168        from xdg.BaseDirectory import xdg_config_home
     169        userdir_file = os.path.join(xdg_config_home, 'user-dirs.dirs')
     170        try:
     171            for line in open(userdir_file, 'r'):
     172                if not line.startswith('#') and 'XDG_DOWNLOAD_DIR' in line:
     173                        download_dir = os.path.expandvars(\
     174                                        line.partition("=")[2].rstrip().strip('"'))
     175                        if os.path.isdir(download_dir):
     176                            return download_dir
     177        except IOError:
     178            pass
     179
    168180        return os.environ.get("HOME")
    169181
     
    528540    return path
    529541
    530 XML_ESCAPES = ( 
     542XML_ESCAPES = (
    531543    ('&', '&amp;'),
    532544    ('<', '&lt;'),
     
    537549
    538550def xml_decode(string):
    539     """ 
     551    """
    540552    Unescape a string that was previously encoded for use within xml.
    541    
     553
    542554    :param string: The string to escape
    543555    :type string: string
     
    550562
    551563def xml_encode(string):
    552     """ 
     564    """
    553565    Escape a string for use within an xml element or attribute.
    554    
     566
    555567    :param string: The string to escape
    556568    :type string: string
Note: See TracChangeset for help on using the changeset viewer.