@@ -54,11 +54,7 @@ def can_cache_bundle(self, descriptor):
5454 :raises RuntimeError: If six.moves is not available.
5555 """
5656 descd = descriptor .get_dict ()
57- # Some descriptors like shotgun descriptors don't have a path: ignore
58- # them.
59- if not descd .get ("path" ):
60- return False
61- return bool (self ._should_download_release (descd ["path" ]))
57+ return bool (self ._should_download_release (descd ))
6258
6359 def populate_bundle_cache_entry (self , destination , descriptor , ** kwargs ):
6460 """
@@ -92,7 +88,7 @@ def populate_bundle_cache_entry(self, destination, descriptor, **kwargs):
9288 descd = descriptor .get_dict ()
9389 version = descriptor .version
9490 self .logger .info ("Treating %s" % descd )
95- specs = self ._should_download_release (descd [ "path" ] )
91+ specs = self ._should_download_release (descd )
9692 if not specs :
9793 raise RuntimeError ("Don't know how to download %s" % descd )
9894 name = specs [0 ]
@@ -142,7 +138,7 @@ def populate_bundle_cache_entry(self, destination, descriptor, **kwargs):
142138 for asset in response_d ["assets" ]:
143139 name = asset ["name" ]
144140 m = re .match (
145- "%s-py\d.\d-%s.zip" % (version , pname ),
141+ r "%s-py\d.\d-%s.zip" % (version , pname ),
146142 name
147143 )
148144 if m :
@@ -171,17 +167,28 @@ def populate_bundle_cache_entry(self, destination, descriptor, **kwargs):
171167 self .logger .exception (e )
172168 raise
173169
174- def _should_download_release (self , desc_path ):
170+ def _should_download_release (self , desc ):
175171 """
176- Return a repo name and a token if the given descriptor path should be downloaded
172+ Return a repo name and a token if the given descriptor should be downloaded
177173 from a github release.
178174
179- :param str desc_path : A Toolkit descriptor path .
175+ :param str desc : A Toolkit descriptor.
180176 :returns: A name, token tuple or ``None``.
181177 """
182- for name , token in self ._download_release_from_github :
183- if "[email protected] :%s.git" % name == desc_path :
184- return name , token
178+ if desc ["type" ] == "github_release" :
179+ # Let's be safe...
180+ if not desc .get ("organization" ) or not desc .get ("repository" ):
181+ return None
182+ desc_path = "%s/%s" % (desc ["organization" ], desc ["repository" ])
183+ for name , token in self ._download_release_from_github :
184+ if name == desc_path :
185+ return name , token
186+ elif desc .get ("path" ):
187+ # Check the path for a git descriptor
188+ desc_path = desc ["path" ]
189+ for name , token in self ._download_release_from_github :
190+ if "[email protected] :%s.git" % name == desc_path :
191+ return name , token
185192 return None
186193
187194 def _download_zip_github_asset (self , asset , destination , token ):
0 commit comments