@@ -106,7 +106,7 @@ def __init__(self, source, tag=None, subdir=None):
106
106
self .url = "ssh://" + source
107
107
else :
108
108
self .url = "https://" + source
109
-
109
+ self . _library_url = None
110
110
self .is_cloned = False
111
111
112
112
self .tag = tag
@@ -126,16 +126,21 @@ def library_url(self):
126
126
"""
127
127
Retrieve the web url, either pages or (eventually) custom.
128
128
"""
129
+ if self ._library_url is not None :
130
+ return self ._library_url
129
131
url = self .url
130
132
if url .endswith (".git" ):
131
133
url = url [:- 4 ]
132
134
parts = url .split ("/" )
133
135
domain = parts [2 ]
134
136
if domain in self .library_url_schemes :
135
- return self .library_url_schemes [domain ] % (
137
+ self . _library_url = self .library_url_schemes [domain ] % (
136
138
parts [3 ],
137
139
"/" .join (parts [4 :]),
138
140
)
141
+ else :
142
+ self ._library_url = ""
143
+ return self ._library_url
139
144
140
145
def exists (self , name ):
141
146
"""
@@ -184,11 +189,10 @@ def _update_cache(self, force=False):
184
189
if self ._cache and not force :
185
190
return
186
191
187
- library_url = self .library_url
188
- if library_url is None :
192
+ if not self .library_url :
189
193
return self ._update_clone_cache ()
190
194
# Check for exposed library API on GitHub or GitLab pages
191
- response = requests .get (library_url )
195
+ response = requests .get (self . library_url )
192
196
if response .status_code != 200 :
193
197
return self ._update_clone_cache ()
194
198
self ._cache = response .json ()
0 commit comments