-
-
Save HamGuy/c8672c13b4d90bdd9d8a455d3db5bef1 to your computer and use it in GitHub Desktop.
Convert Mac model strings into general category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns dictionary mapping lowercase model strings (e.g. 'macbookpro11,3') | |
# to a general category (e.g. "MacBook Pro (15-inch)"). | |
# Exact model names can be modified. | |
# @author Richard Hofman | |
# | |
def model_to_type_dict(): | |
type_to_model = {'Macbook Pro (Retina, 13-inch)': ['MacBookPro10,2', 'MacBookPro11,1', 'MacbookPro12,1'], | |
'MacBook Pro (13-inch)': ['MacBookPro9,2', 'MacBookPro8,1', 'MacBookPro7,1', 'MacBookPro5,5'], | |
'MacBook Pro (Retina, 15-inch)': ['MacbookPro11,4', 'MacbookPro11,5', 'MacBookPro11,2', 'MacBookPro11,3', 'MacBookPro10,1'], | |
'MacBook Pro (15-inch)': ['MacBookPro9,1', 'MacBookPro8,2', 'MacBookPro6,2', 'MacBookPro5,3', 'MacBookPro5,1', 'MacBookPro4,1', 'MacBookPro3,1', 'MacBookPro2,2', 'MacBookPro1,1'], | |
'MacBook Air (13-inch)': ['MacBookAir7,2', 'MacBookAir6,2', 'MacBookAir5,2', 'MacBookAir4,2', 'MacBookAir3,2', 'MacBookAir2,1', 'MacBookAir1,1'], | |
'MacBook Air (11-inch)': ['MacBookAir7,1', 'MacBookAir6,1', 'MacBookAir5,1', 'MacBookAir4,1', 'MacBookAir3,1'], | |
'Mac Mini': ['Macmini1,1', 'Macmini2,1', 'Macmini3,1', 'Macmini4,1', 'Macmini5,1','Macmini5,2','Macmini5,3', 'Macmini6,1', 'Macmini6,2', 'Macmini7,1', 'Macmini7,2', 'Macmini7,3'], | |
'iMac (27-inch)': ['iMac17,1', 'iMac15,1', 'iMac14,2', 'iMac13,2', 'iMac12,2', 'iMac11,3'], | |
'iMac (21-inch)': ['iMac16,2', 'iMac16,1', 'iMac14,4', 'iMac14,1', 'iMac13,1', 'iMac12,1', 'iMac11,2', 'iMac10,1'] | |
} | |
model_to_type = {} | |
# Invert the map dictionary | |
for type,models in type_to_model.items(): | |
for model in models: | |
model_to_type[model.lower()] = type | |
return model_to_type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment