/[navidoc]/navidoc/navidoc/utils/path.py
ViewVC logotype

Diff of /navidoc/navidoc/utils/path.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by humppake, Fri Mar 28 13:08:57 2003 UTC revision 1.8 by humppake, Tue Apr 1 13:54:10 2003 UTC
# Line 55  def relative_path(source, target): Line 55  def relative_path(source, target):
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
# Line 64  def relative_path(source, target): Line 67  def relative_path(source, target):
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('/')
# Line 80  def relative_path(source, target): Line 88  def relative_path(source, target):
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])

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26