def github_belspec_files(spec_dir, force: bool = False):
    """Get belspec files from Github repo


    Args:
        spec_dir: directory to store the BEL Specification and derived files
        force: force update of BEL Specifications from Github - skipped if local files less than 1 day old
    """

    if not force:
        dtnow = datetime.datetime.utcnow()
        delta = datetime.timedelta(1)
        yesterday = dtnow - delta

        for fn in glob.glob(f"{spec_dir}/bel*yaml"):
            if datetime.datetime.fromtimestamp(os.path.getmtime(fn)) > yesterday:
                log.info("Skipping BEL Specification update - specs less than 1 day old")
                return

    repo_url = "https://api.github.com/repos/belbio/bel_specifications/contents/specifications"
    params = {}
    github_access_token = os.getenv("GITHUB_ACCESS_TOKEN", "")
    if github_access_token:
        params = {"access_token": github_access_token}

    r = requests.get(repo_url, params=params)
    if r.status_code == 200:
        results = r.json()
        for f in results:
            url = f["download_url"]
            fn = os.path.basename(url)

            if "yaml" not in fn and "yml" in fn:
                fn = fn.replace("yml", "yaml")

            r = requests.get(url, params=params, allow_redirects=True)
            if r.status_code == 200:
                open(f"{spec_dir}/{fn}", "wb").write(r.content)
            else:
                sys.exit(
                    f"Could not get BEL Spec file {url} from Github -- Status: {r.status_code}  Msg: {r.content}"
                )
    else:
        sys.exit(
            f"Could not get BEL Spec directory listing from Github -- Status: {r.status_code}  Msg: {r.content}"
        )
def github_belspec_files ( spec_dir , force : bool = False ) : if not force : dtnow = datetime . datetime . utcnow ( ) delta = datetime . timedelta ( 1 ) yesterday = dtnow - delta for fn in glob . glob ( f"{spec_dir}/bel*yaml" ) : if datetime . datetime . fromtimestamp ( os . path . getmtime ( fn ) ) > yesterday : log . info ( "Skipping BEL Specification update - specs less than 1 day old" ) return repo_url = "https://api.github.com/repos/belbio/bel_specifications/contents/specifications" params = { } github_access_token = os . getenv ( "GITHUB_ACCESS_TOKEN" , "" ) if github_access_token : params = { "access_token" : github_access_token } r = requests . get ( repo_url , params = params ) if r . status_code == 200 : results = r . json ( ) for f in results : url = f [ "download_url" ] fn = os . path . basename ( url ) if "yaml" not in fn and "yml" in fn : fn = fn . replace ( "yml" , "yaml" ) r = requests . get ( url , params = params , allow_redirects = True ) if r . status_code == 200 : open ( f"{spec_dir}/{fn}" , "wb" ) . write ( r . content ) else : sys . exit ( f"Could not get BEL Spec file {url} from Github -- Status: {r.status_code}  Msg: {r.content}" ) else : sys . exit ( f"Could not get BEL Spec directory listing from Github -- Status: {r.status_code}  Msg: {r.content}" )
Get belspec files from Github repo


    Args:
        spec_dir: directory to store the BEL Specification and derived files
        force: force update of BEL Specifications from Github - skipped if local files less than 1 day old