Skip to content

Commit

Permalink
Small improvement for the profiler.format_fname method to make it wor…
Browse files Browse the repository at this point in the history
…k on windows (hopefully).
  • Loading branch information
mvantellingen committed Feb 6, 2011
1 parent cee7783 commit e591b3c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions flaskext/debugtoolbar/panels/profiler.py
Expand Up @@ -115,9 +115,11 @@ def format_fname(value):
# If the value is not an absolute path, the it is a builtin or
# a relative file (thus a project file).
if not os.path.isabs(value):
if value.startswith('{'):
if value.startswith(('{', '<')):
return value
return './' + value
if value.startswith('.' + os.path.sep):
return value
return '.' + os.path.sep + value

# If the file is absolute and within the project root handle it as
# a project file
Expand All @@ -135,7 +137,7 @@ def format_fname(value):
prefix = new_prefix
prefix_len = len(prefix)

if not prefix.endswith('/'):
if not prefix.endswith(os.path.sep):
prefix_len -= 1
path = value[prefix_len:]
return '<%s>' % path

0 comments on commit e591b3c

Please sign in to comment.