Mercurial > hg > config
view python/relativelink.py @ 783:d564f7ad8294
this now works again, and without docker-machine; ephermal testing for now, ephemeral testing forever
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Wed, 24 Aug 2016 14:39:51 -0700 |
parents | 09c10061838c |
children |
line wrap: on
line source
#!/usr/bin/env python def link(path_info, path=None): segments = path_info.split('/') if segments[0]: segments.insert(0, '') if len(segments) <3: if not path or path == '/': return './' return path nlayers = len(segments[2:]) string = '../' * nlayers if not path or path == '/': return string return string + path if __name__ == '__main__': import sys assert len(sys.argv[1:]) == 2, "need two arguments" path_info, path = sys.argv[1:] print link(path_info, path)