[issue5117] os.path.relpath problem with root directory
Jim Blandy
report at bugs.python.org
Wed Mar 4 23:01:23 CET 2009
Jim Blandy <jimb at red-bean.com> added the comment:
In case the behavior requested here is controversial, here's an example
of where it would be nice to have relpath(x, '/') return a path for x
that is relative to the root directory:
The 'oprofile' system profiler for Linux profiles everything running on
the system at once. Its profile count database takes the form of a
directory tree of counter files that mirrors the whole filesystem:
/var/lib/oprofile/samples/current/{root}/bin/ls holds the samples for
/bin/ls, and so on. Also, the 'opannotate' command annotates source
trees with profile counts: if /bin/ls were built from /src/ls.c, then
'opannotate -o ~/ann-tree' would put a count-annotated copy of ls's
source '~/ann-tree/src/ls.c'.
At the moment, I wish I could simply say:
src=path to source file
real_src = os.path.realpath(src)
rel_real_src = os.path.relpath(real_src, '/')
annotated_source = os.path.join(annotation_dir, rel_real_src)
but this bug gets in the way.
----------
nosy: +jimb
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5117>
_______________________________________
More information about the Python-bugs-list
mailing list