Nautilus integration: Work with python2 and python3

This commit is contained in:
Christian Kamm 2018-01-23 11:47:23 +01:00 committed by Olivier Goffart
parent f254ee3211
commit 72363155d8

View file

@ -15,9 +15,13 @@
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details. # for more details.
import sys
python3 = sys.version_info[0] >= 3
import os import os
import urllib import urllib
import urllib.parse if python3:
import urllib.parse
import socket import socket
import tempfile import tempfile
@ -31,11 +35,11 @@ appname = 'ownCloud'
print("Initializing "+appname+"-client-nautilus extension") print("Initializing "+appname+"-client-nautilus extension")
def get_local_path(url): def get_local_path(url):
if url[0:7] == 'file://': if url[0:7] == 'file://':
url = url[7:] url = url[7:]
return urllib.parse.unquote(url) unquote = urllib.parse.unquote if python3 else urllib.unquote
return unquote(url)
def get_runtime_dir(): def get_runtime_dir():
"""Returns the value of $XDG_RUNTIME_DIR, a directory path. """Returns the value of $XDG_RUNTIME_DIR, a directory path.