Clone of official tools

Revision:
35:da9c89f8be7d
Parent:
31:8ea194f6145b
Child:
36:96847d42f010
diff -r 42f20e28adf5 -r da9c89f8be7d arm_pack_manager/__init__.py
--- a/arm_pack_manager/__init__.py	Mon Feb 13 09:29:13 2017 -0600
+++ b/arm_pack_manager/__init__.py	Wed Feb 15 13:53:18 2017 -0600
@@ -26,7 +26,8 @@
     return protocol_matcher.sub("", str(url))
 
 def largest_version(content) :
-    return sorted([t['version'] for t in content.package.releases('release')], reverse=True)[0]
+    return sorted([t['version'] for t in content.package.releases('release')],
+                  reverse=True, key=lambda v: map(int, v.split(".")))[0]
 
 def do_queue(Class, function, interable) :
     q = Queue()
@@ -251,8 +252,9 @@
         :return: A file-like object that, when read, is the ELF file that describes the flashing algorithm
         :rtype: ZipExtFile
         """
-        pack = self.pack_from_cache(self.index[device_name])
-        return pack.open(device['algorithm']['file'])
+        device = self.index[device_name]
+        pack = self.pack_from_cache(device)
+        return pack.open(device['algorithm'].keys()[0])
 
     def get_svd_file(self, device_name) :
         """Retrieve the flash algorithm file for a particular part.
@@ -264,7 +266,8 @@
         :return: A file-like object that, when read, is the ELF file that describes the flashing algorithm
         :rtype: ZipExtFile
         """
-        pack = self.pack_from_cache(self.index[device_name])
+        device = self.index[device_name]
+        pack = self.pack_from_cache(device)
         return pack.open(device['debug'])
 
     def generate_index(self) :
@@ -407,7 +410,7 @@
         with open(dest, "r") as fd :
             return BeautifulSoup(fd, "html.parser")
 
-    def pack_from_cache(self, url) :
+    def pack_from_cache(self, device) :
         """Low level inteface for extracting a PACK file from the cache.
 
         Assumes that the file specified is a PACK file and is in the cache.