You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
476 B

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