blob: d3f9e081381cfbc00450777a59d5f14d5346a54a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
from __future__ import unicode_literals
import os.path
import re
from django.utils import six
# backport of Python 3.4's glob.escape
if six.PY3:
from glob import escape as glob_escape
else:
_magic_check = re.compile('([*?[])')
def glob_escape(pathname):
"""
Escape all special characters.
"""
drive, pathname = os.path.splitdrive(pathname)
pathname = _magic_check.sub(r'[\1]', pathname)
return drive + pathname
|