Improve handling of bare drive letters like "D:"

This commit is contained in:
Ethan Dalool 2018-01-21 14:20:56 -08:00
parent 93d42afeca
commit 81e44363e7

View file

@ -1,5 +1,6 @@
import glob import glob
import os import os
import re
class Path: class Path:
''' '''
@ -9,6 +10,10 @@ class Path:
if isinstance(path, Path): if isinstance(path, Path):
self.absolute_path = path.absolute_path self.absolute_path = path.absolute_path
else: else:
path = path.strip()
if re.search('[A-Za-z]:$', path):
# Bare Windows drive letter.
path += os.sep
path = normalize_sep(path) path = normalize_sep(path)
path = os.path.normpath(path) path = os.path.normpath(path)
path = os.path.abspath(path) path = os.path.abspath(path)
@ -198,6 +203,8 @@ def get_path_casing(path):
imaginary_portion = imaginary_portion.lstrip(os.sep) imaginary_portion = imaginary_portion.lstrip(os.sep)
cased = os.path.join(cased, imaginary_portion) cased = os.path.join(cased, imaginary_portion)
cased = cased.rstrip(os.sep) cased = cased.rstrip(os.sep)
if not os.sep in cased:
cased += os.sep
return cased return cased
def glob_patternize(piece): def glob_patternize(piece):