Am 21.06.2012 12:23, schrieb Armin Ronacher: > Due to an user error on my part I was not using os.readlink correctly. > Since links can be relative to their location I think it would make sense > to provide an os.path.resolve helper that automatically returns the > absolute path: > > def resolve(filename): > try: > target = os.readlink(filename) > except OSError as e: > if e.errno == errno.EINVAL: > return abspath(filename) > raise > return normpath(join(dirname(filename), target)) > > The above implementation also does not fail if an entity exists but is not > a link and just returns the absolute path of the given filename in that > case. +1 Does the code handle a chain of absolute and relative symlinks correctly, for example a relative symlink that points to another relative symlink in a different directory that points to a file in a third directry? Christian
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4