S
Stef Mientki
hello,
when getting a breakpoint from pdb and similar packages,
on Windows, the filename is given in lowercase.
For the caption of my editor, I need the filename in the correct case.
The function below does work reasonable well (path is not in the correct
case),
but I find it weird and much too difficult.
Does anyone has a better solution ?
thanks,
Stef Mientki
# ***********************************************************************
# ***********************************************************************
def Get_PDB_Windows_Filename ( FileName ) :
"""
On windows systems,
Translates the Filename to the correct case
the preceding absolute or relative path is converted to lower case !!
Used to translate filenames coming from PDB and similar packages
On other OS, it just returns the unmodified string
"""
if os.name == 'nt' :
# path will be translated to lowercase
# and we want only forward slashes
FileName = FileName.lower ().replace ( '\\', '/' )
# Do a search with some degrees of freedom
# otherwise glob.glob just returns the original string !!
Result = glob.glob ( FileName [:-1] + '*')
if Result:
for R in Result :
if R.lower().replace( '\\', '/' ) == FileName :
return R.replace ( '\\', '/' )
return FileName
# ***********************************************************************
when getting a breakpoint from pdb and similar packages,
on Windows, the filename is given in lowercase.
For the caption of my editor, I need the filename in the correct case.
The function below does work reasonable well (path is not in the correct
case),
but I find it weird and much too difficult.
Does anyone has a better solution ?
thanks,
Stef Mientki
# ***********************************************************************
# ***********************************************************************
def Get_PDB_Windows_Filename ( FileName ) :
"""
On windows systems,
Translates the Filename to the correct case
the preceding absolute or relative path is converted to lower case !!
Used to translate filenames coming from PDB and similar packages
On other OS, it just returns the unmodified string
"""
if os.name == 'nt' :
# path will be translated to lowercase
# and we want only forward slashes
FileName = FileName.lower ().replace ( '\\', '/' )
# Do a search with some degrees of freedom
# otherwise glob.glob just returns the original string !!
Result = glob.glob ( FileName [:-1] + '*')
if Result:
for R in Result :
if R.lower().replace( '\\', '/' ) == FileName :
return R.replace ( '\\', '/' )
return FileName
# ***********************************************************************