55 |
""" |
""" |
56 |
Returns a relative path from the source to the target. |
Returns a relative path from the source to the target. |
57 |
""" |
""" |
58 |
|
import config |
59 |
|
dbg = config.dbg.shorthand('path') |
60 |
|
|
61 |
if source == None or len(source) == 0: return target |
if source == None or len(source) == 0: return target |
62 |
|
|
63 |
## Condition removed because because of docutils sending |
## Condition removed because because of docutils sending |
67 |
source = os.path.normpath(os.path.abspath(source)) |
source = os.path.normpath(os.path.abspath(source)) |
68 |
target = os.path.normpath(os.path.abspath(target)) |
target = os.path.normpath(os.path.abspath(target)) |
69 |
|
|
70 |
|
if os.path.isdir(source): source = slashify(source) |
71 |
|
if os.path.isdir(target): target = slashify(target) |
72 |
|
|
73 |
|
dbg('Source: %s, Target: %s' % (source, target)) |
74 |
|
|
75 |
depth = source.count('/') |
depth = source.count('/') |
76 |
source_parts = source.split('/') |
source_parts = source.split('/') |
77 |
target_parts = target.split('/') |
target_parts = target.split('/') |
88 |
+''.join([target_parts[i+parts]+'/' \ |
+''.join([target_parts[i+parts]+'/' \ |
89 |
for i in range(len(target_parts)-parts)]) |
for i in range(len(target_parts)-parts)]) |
90 |
|
|
91 |
|
dbg('Relative path: '+relative[0:len(relative)-1]) |
92 |
return (relative[0:len(relative)-1]) |
return (relative[0:len(relative)-1]) |