mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-23 02:16:01 +01:00
Optimize Node.path_from
This commit is contained in:
parent
ea032a73ae
commit
0dd0e17ecc
@ -56,7 +56,8 @@ def test(ctx):
|
||||
tt('path_from', dd.path_from(pp), os.path.split(os.getcwd())[1])
|
||||
tt('path_from (reverse)', pp.path_from(dd), '..')
|
||||
tt('same path', pp.path_from(pp), '.')
|
||||
tt('same_root', bld.root.path_from(bld.root), '.')
|
||||
tt('path from root is abspath()', pp.path_from(bld.root), pp.abspath())
|
||||
tt('root from root', bld.root.path_from(bld.root), bld.root.abspath())
|
||||
|
||||
tt('root height', bld.root.height(), 0)
|
||||
tt('self height', dd.height(), len(absdir))
|
||||
|
@ -430,10 +430,9 @@ class Node(object):
|
||||
|
||||
:param node: path to use as a reference
|
||||
:type node: :py:class:`waflib.Node.Node`
|
||||
:returns: the relative path
|
||||
:returns: a relative path or an absolute one if that is better
|
||||
:rtype: string
|
||||
"""
|
||||
|
||||
c1 = self
|
||||
c2 = node
|
||||
|
||||
@ -461,13 +460,11 @@ class Node(object):
|
||||
c2 = c2.parent
|
||||
|
||||
if c1.parent:
|
||||
for i in range(up):
|
||||
lst.append('..')
|
||||
lst.extend(['..'] * up)
|
||||
lst.reverse()
|
||||
return os.sep.join(lst) or '.'
|
||||
else:
|
||||
if lst and not Utils.is_win32:
|
||||
lst.append('')
|
||||
lst.reverse()
|
||||
return os.sep.join(lst) or '.'
|
||||
return self.abspath()
|
||||
|
||||
def abspath(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user