mirror of
https://git.deluge-torrent.org/deluge
synced 2025-09-02 16:15:32 +00:00
Add XDG_DOWNLOAD_DIR for default download folder #1788
This commit is contained in:
parent
14c3655ba1
commit
83283cdcf3
1 changed files with 17 additions and 5 deletions
|
@ -165,6 +165,18 @@ def get_default_download_dir():
|
||||||
if windows_check():
|
if windows_check():
|
||||||
return os.path.expanduser("~")
|
return os.path.expanduser("~")
|
||||||
else:
|
else:
|
||||||
|
from xdg.BaseDirectory import xdg_config_home
|
||||||
|
userdir_file = os.path.join(xdg_config_home, 'user-dirs.dirs')
|
||||||
|
try:
|
||||||
|
for line in open(userdir_file, 'r'):
|
||||||
|
if not line.startswith('#') and 'XDG_DOWNLOAD_DIR' in line:
|
||||||
|
download_dir = os.path.expandvars(\
|
||||||
|
line.partition("=")[2].rstrip().strip('"'))
|
||||||
|
if os.path.isdir(download_dir):
|
||||||
|
return download_dir
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
|
||||||
return os.environ.get("HOME")
|
return os.environ.get("HOME")
|
||||||
|
|
||||||
def windows_check():
|
def windows_check():
|
||||||
|
@ -527,7 +539,7 @@ def path_join(*parts):
|
||||||
path += '/' + part
|
path += '/' + part
|
||||||
return path
|
return path
|
||||||
|
|
||||||
XML_ESCAPES = (
|
XML_ESCAPES = (
|
||||||
('&', '&'),
|
('&', '&'),
|
||||||
('<', '<'),
|
('<', '<'),
|
||||||
('>', '>'),
|
('>', '>'),
|
||||||
|
@ -536,9 +548,9 @@ XML_ESCAPES = (
|
||||||
)
|
)
|
||||||
|
|
||||||
def xml_decode(string):
|
def xml_decode(string):
|
||||||
"""
|
"""
|
||||||
Unescape a string that was previously encoded for use within xml.
|
Unescape a string that was previously encoded for use within xml.
|
||||||
|
|
||||||
:param string: The string to escape
|
:param string: The string to escape
|
||||||
:type string: string
|
:type string: string
|
||||||
:returns: The unescaped version of the string.
|
:returns: The unescaped version of the string.
|
||||||
|
@ -549,9 +561,9 @@ def xml_decode(string):
|
||||||
return string
|
return string
|
||||||
|
|
||||||
def xml_encode(string):
|
def xml_encode(string):
|
||||||
"""
|
"""
|
||||||
Escape a string for use within an xml element or attribute.
|
Escape a string for use within an xml element or attribute.
|
||||||
|
|
||||||
:param string: The string to escape
|
:param string: The string to escape
|
||||||
:type string: string
|
:type string: string
|
||||||
:returns: An escaped version of the string.
|
:returns: An escaped version of the string.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue