1515 BuildRunnerProtocolError ,
1616)
1717
18+ def _clean_nones (items ):
19+ return list (filter (None , items ))
1820
19- def v3_fetch_file (parsed_url , gh_config : GithubModel ):
21+
22+ def _fetch_file (parsed_url , gh_config : GithubModel ):
2023 """
2124 Fetch files using Github v3 protocol.
2225 """
@@ -30,12 +33,12 @@ def v3_fetch_file(parsed_url, gh_config: GithubModel):
3033
3134 auth = (username , gh_config .app_token )
3235 url = "/" .join (
33- (
36+ _clean_nones ([
3437 endpoint ,
3538 version ,
3639 "users" ,
3740 username ,
38- )
41+ ] )
3942 )
4043 resp = requests .get (url , auth = auth , timeout = 180 )
4144 if resp .status_code != 200 :
@@ -47,7 +50,7 @@ def v3_fetch_file(parsed_url, gh_config: GithubModel):
4750 raise ValueError ('URL must begin with "/"' )
4851
4952 fpath = parsed_url .path .split ("/" )
50- ubuild = [endpoint , version , "repos" , fpath [1 ], fpath [2 ], "contents" ]
53+ ubuild = _clean_nones ( [endpoint , version , "repos" , fpath [1 ], fpath [2 ], "contents" ])
5154 ubuild .extend (fpath [3 :])
5255 url = "/" .join (ubuild )
5356 resp = requests .get (url , auth = auth , timeout = 180 )
@@ -97,9 +100,9 @@ def fetch_file(parsed_url, config: GlobalConfig):
97100 )
98101
99102 ver = nlcfg .version
100- # NOTE: potentially the v3_fetch_file () works for other github API versions.
101- if ver == "v3" :
102- contents = v3_fetch_file (parsed_url , nlcfg )
103+ # NOTE: potentially the _fetch_file () works for other github API versions.
104+ if ver == "v3" or ver is None :
105+ contents = _fetch_file (parsed_url , nlcfg )
103106 else :
104107 raise NotImplementedError (f"No version support for github API version { ver } " )
105108
0 commit comments