Commit 3c6bb0f4 by willmcgugan@gmail.com

simpler version of relativefrom

parent e16a1357
...@@ -411,12 +411,13 @@ def relativefrom(base, path): ...@@ -411,12 +411,13 @@ def relativefrom(base, path):
base = list(iteratepath(base)) base = list(iteratepath(base))
path = list(iteratepath(path)) path = list(iteratepath(path))
while base and path and base[0] == path[0]: common = 0
base.pop(0) for a, b in zip(base, path):
path.pop(0) if a != b:
break
common += 1
# If you multiply a list by a negative number, you get an empty list! return u'/'.join([u'..'] * (len(base) - common) + path[common:])
return u'/'.join([u'..'] * len(base) + path)
class PathMap(object): class PathMap(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment