Пример #1
0
 def _quote_paths(self, paths, start, end):
     out = set()
     space = ' '
     backslash = '\\'
     double_backslash = '\\\\'
     slash = get_sep()
     orig_start = start
     orig_end = end
     for s in paths:
         start = orig_start
         end = orig_end
         if (start == '' and
                 (any(i in s for i in CHARACTERS_NEED_QUOTES) or
                  (backslash in s and slash != backslash))):
             start = end = self._quote_to_use(s)
         if os.path.isdir(expand_path(s)):
             _tail = slash
         elif end == '':
             _tail = space
         else:
             _tail = ''
         s = s + _tail
         if end != '':
             if "r" not in start.lower():
                 s = s.replace(backslash, double_backslash)
             elif s.endswith(backslash):
                 s += backslash
         if end in s:
             s = s.replace(end, ''.join('\\%s' % i for i in end))
         out.add(start + s + end)
     return out
Пример #2
0
 def _quote_paths(self, paths, start, end):
     out = set()
     space = ' '
     backslash = '\\'
     double_backslash = '\\\\'
     slash = get_sep()
     for s in paths:
         if (start == '' and
                 (space in s or (backslash in s and slash != backslash))):
             start = "'"
             end = "'"
         if os.path.isdir(expand_path(s)):
             _tail = slash
         elif end == '':
             _tail = space
         else:
             _tail = ''
         s = s + _tail
         if end != '':
             if "r" not in start.lower():
                 s = s.replace(backslash, double_backslash)
             elif s.endswith(backslash):
                 s += backslash
         out.add(start + s + end)
     return out
Пример #3
0
def test_expand_path(s, home_env):
    if os.sep != "/":
        s = s.replace("/", os.sep)
    if os.pathsep != ":":
        s = s.replace(":", os.pathsep)
    assert expand_path(s) == s.replace("~", HOME_PATH)
Пример #4
0
def test_expand_path(s, home_env):
    if os.sep != '/':
        s = s.replace('/', os.sep)
    if os.pathsep != ':':
        s = s.replace(':', os.pathsep)
    assert expand_path(s) == s.replace('~', HOME_PATH)
Пример #5
0
def test_expand_path(s, home_env):
    if os.sep != '/':
        s = s.replace('/', os.sep)
    if os.pathsep != ':':
        s = s.replace(':', os.pathsep)
    assert expand_path(s) == s.replace('~', HOME_PATH)
Пример #6
0
def test_expand_path(s, home_env):
    if os.sep != "/":
        s = s.replace("/", os.sep)
    if os.pathsep != ":":
        s = s.replace(":", os.pathsep)
    assert expand_path(s) == s.replace("~", HOME_PATH)