How to get the filename in the right case ?
Stef Mientki
stef.mientki at gmail.com
Thu Sep 25 19:46:15 EDT 2008
Fredrik Lundh wrote:
> Stef Mientki wrote:
>
> > 1. I've a multitab editor.
> > 2. When a breakpoint is reached,
> > 3. I check if the file specified in pdb output, is already open in one
> > of the editor tabs,
> > 4. if not, I open a new tab with the correct file,
> > 5. I focus the correct editor tab and jump to the line specified by
> > pdb.
> > 6. After that I should be able to inspect the surrounding of the
> > breakpoint, so I need the modules name.
> >
> > For 3 I need to compare filenames, the editor contains the case
> > sensitive name, pdb not.
>
> pdb uses os.path.abspath and os.path.normcase to normalize filenames
> so they can be safely compared (see the canonic method in bdb.py).
>
> I suggest you do the same in your editor; e.g:
Frederik thanks for the clarification.
I don't think your suggestion is a good one.
If a filename has uppercase characters in it,
the END-USER has done that for some kind of reason.
I as a programmer have to respect the arguments of the END-USER,
(whatever they are),
so I need to visualize the real filename.
Secondly thoughtless copying of current behavior, doesn't bring any
progress,
and I think that's one of the reasons why we're still burdened by
inventions done 20 years ago,
e.g. "do you want to save your changes ?".
cheers,
Stef
>
> pdb_filename = ...
>
> for buffer in editor_buffers:
> filename = os.path.normcase(os.path.abspath(buffer.filename))
> if pdb == filename:
> ... found it ...
> break
>
> </F>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list