code refactoring - added functions posixToNtSlashes and ntToPosixSlashes

This commit is contained in:
Miroslav Stampar
2010-02-04 14:37:00 +00:00
parent a1e80e77a1
commit ec63fc4036
7 changed files with 37 additions and 24 deletions

View File

@@ -236,15 +236,15 @@ def getDocRoot():
absFilePathWin = None
if isWindowsPath(absFilePath):
absFilePathWin = absFilePath.replace("/", "\\")
absFilePath = absFilePath[2:].replace("\\", "/")
absFilePathWin = posixToNtSlashes(absFilePath)
absFilePath = ntToPosixSlashes(absFilePath[2:])
if pagePath in absFilePath:
index = absFilePath.index(pagePath)
docRoot = absFilePath[:index]
if absFilePathWin:
docRoot = "C:/%s" % docRoot.replace("\\", "/")
docRoot = "C:/%s" % ntToPosixSlashes(docRoot)
docRoot = normalizePath(docRoot)
break
@@ -908,3 +908,9 @@ def decloakToMkstemp(filepath, **kwargs):
def isWindowsPath(filepath):
return re.search("\A[A-Za-z]:", filepath) is not None
def posixToNtSlashes(filepath):
return filepath.replace('/', '\\')
def ntToPosixSlashes(filepath):
return filepath.replace('\\', '/')