[Console] Refactor console config command for windows paths

Parse windows paths regardless of console running on a windows machine.
This commit is contained in:
Calum Lind 2017-11-05 17:17:00 +00:00
parent e33a8fbea4
commit b8e5ebe822
2 changed files with 5 additions and 8 deletions

View file

@ -34,7 +34,6 @@
#
#
from deluge.common import windows_check
from deluge.ui.console.main import BaseCommand
import deluge.ui.console.colors as colors
from deluge.ui.client import client
@ -43,7 +42,6 @@ from deluge.log import LOG as log
from optparse import make_option
import re
import string
import cStringIO, tokenize
@ -79,11 +77,11 @@ def atom(next, token):
return False
elif token[0] is tokenize.STRING or token[1] == "/":
return token[-1].decode("string-escape")
elif windows_check() and token[1].lower() in string.lowercase:
# Parse Windows paths e.g. 'C:\xyz'.
token = next()
if token[1] == ":":
elif token[1].isalpha():
# Parse Windows paths e.g. 'C:\\xyz' or 'C:/xyz'.
if next()[1] == ":" and next()[1] in '\/':
return token[-1].decode("string-escape")
raise SyntaxError("malformed expression (%s)" % token[1])
def simple_eval(source):

View file

@ -110,8 +110,7 @@ class BaseCommand(object):
return self.__doc__
def split(self, text):
if deluge.common.windows_check():
text = text.replace('\\', '\\\\')
text = text.replace('\\', '\\\\')
return shlex.split(text)
def create_parser(self):