From 72363155d86b4b51b1bfbd75c7a4a19fed3f8ee9 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 23 Jan 2018 11:47:23 +0100 Subject: [PATCH] Nautilus integration: Work with python2 and python3 --- shell_integration/nautilus/syncstate.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shell_integration/nautilus/syncstate.py b/shell_integration/nautilus/syncstate.py index 6ea719100..77a233d3d 100644 --- a/shell_integration/nautilus/syncstate.py +++ b/shell_integration/nautilus/syncstate.py @@ -15,9 +15,13 @@ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. +import sys +python3 = sys.version_info[0] >= 3 + import os import urllib -import urllib.parse +if python3: + import urllib.parse import socket import tempfile @@ -31,11 +35,11 @@ appname = 'ownCloud' print("Initializing "+appname+"-client-nautilus extension") - def get_local_path(url): if url[0:7] == 'file://': url = url[7:] - return urllib.parse.unquote(url) + unquote = urllib.parse.unquote if python3 else urllib.unquote + return unquote(url) def get_runtime_dir(): """Returns the value of $XDG_RUNTIME_DIR, a directory path.