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

View file

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