looper/resolve_library.py
2024-09-16 15:05:53 -07:00

20 lines
No EOL
552 B
Python
Executable file

#!/usr/bin/env python3
from sys import argv
from os import readlink
from os import path
def resolve(inpath: str) -> list[str]:
output = []
inpath = path.abspath(inpath)
dir=path.dirname(inpath)
while path.islink(inpath):
output.append(inpath)
inpath=readlink(inpath)
if not path.isabs(inpath):
inpath=path.join(dir, inpath)
dir=path.dirname(inpath)
return output
if __name__ == "__main__":
for i in argv[1:]:
paths=resolve(i)
for path in paths:
print(path)