Created
December 7, 2021 16:00
-
-
Save siburu/4972d7645871bb3ebc0e0ac67b25cdd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_import_path(target: str, start: str) -> str: | |
import os | |
target = os.path.join('root', target) | |
start = os.path.join('root', start) | |
d = os.path.relpath(os.path.dirname(target), os.path.dirname(start)) | |
if not d.startswith('.'): | |
d = os.path.join('.', d) | |
return os.path.join(d, os.path.basename(target)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment