freemyipod r549 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r548‎ | r549 | r550 >
Date:02:46, 7 February 2011
Author:farthen
Status:new
Tags:
Comment:
emcore tools: Add shortnames to the hwtypes and include a function that returns their id.
Modified paths:
  • /emcore/trunk/tools/libemcoredata.py (modified) (history)
  • /emcore/trunk/tools/misc.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/libemcoredata.py
@@ -89,9 +89,9 @@
9090 }
9191
9292 hwtypes = {
93 - 0: "invalid",
94 - 0x47324e49: "iPod nano 2g",
95 - 0x47334e49: "iPod nano 3g",
96 - 0x47344e49: "iPod nano 4g",
97 - 0x4c435049: "iPod classic"
98 -}
 93+ 0: ("invalid", "invalid"),
 94+ 0x47324e49: ("ipodnano2g", "iPod nano 2g"),
 95+ 0x47334e49: ("ipodnano3g", "iPod nano 3g"),
 96+ 0x47344e49: ("ipodnano4g", "iPod nano 4g"),
 97+ 0x4c435049: ("ipodclassic", "iPod classic"),
 98+}
\ No newline at end of file
Index: emcore/trunk/tools/misc.py
@@ -227,12 +227,19 @@
228228 def gethwname(id):
229229 try:
230230 from libemcoredata import hwtypes
231 - hwtype = hwtypes[id]
 231+ hwtype = hwtypes[id][1]
232232 except KeyError:
233233 hwtype = "UNKNOWN (ID = 0x%X)" % id
234234 return hwtype
235235
 236+def gethwid(shortname):
 237+ from libemcoredata import hwtypes
 238+ for hwid in hwtypes:
 239+ if hwtypes[hwid][0] == shortname:
 240+ return hwid
 241+ return False
236242
 243+
237244 def trimdoc(docstring):
238245 """
239246 Trims whitespace from docstrings