INNER CODE UNIT · Python

open_or_download

Zverik/every_door · tools/json_to_sqlite.py:95

def open_or_download(git_path: Optional[str], filename: str, from_nsi: bool = False) -> dict:
    """
    Either opens the built json file from given git path
    (adding repo name automatically), or downloads the json
    from git. Returns a parsed dict, since all json files
    we use are dicts and not arrays.
    """
    if git_path:
        fullname = os.path.join(git_path, filename)
        if not os.path.exists(fullname):
            if from_nsi:
                git_name = 'name-suggestion-index'
            else:
                git_name = 'id-tagging-schema'
            fullname = os.path.join(git_path, git_name, 'dist', filename)
            if not os.path.exists(fullname):
                print(f'Cannot find {filename} under {git_path}')
                sys.exit(2)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…