From ef5a2503979100537d92a558a173f5ec32716988 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Tue, 10 Dec 2013 10:41:58 +0200 Subject: Added is_mac property --- gsxws/products.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'gsxws') diff --git a/gsxws/products.py b/gsxws/products.py index de83b25..38a0b7a 100644 --- a/gsxws/products.py +++ b/gsxws/products.py @@ -3,6 +3,7 @@ """ https://gsxwsut.apple.com/apidocs/ut/html/WSAPIChangeLog.html?user=asp """ +import re import urllib from lookups import Lookup @@ -25,7 +26,7 @@ class Product(object): """ Something serviceable made by Apple """ - def __init__(self, sn): + def __init__(self, sn, **kwargs): if validate(sn, 'alternateDeviceId'): self.alternateDeviceId = sn self._gsx = GsxObject(alternateDeviceId=sn) @@ -156,10 +157,18 @@ class Product(object): policy = ad.nextTetherPolicyDetails or '' return ad.unlocked or ("unlock" in policy) + @property + def is_locked(self): + return not self.is_unlocked() + @property def should_check_activation(self): return hasattr(self, "alternateDeviceId") and not hasattr(self, "serialNumber") + @property + def is_mac(self): + return re.match(r'^i?Mac', self.description) + @property def is_iphone(self): return self.description.startswith('iPhone') @@ -181,10 +190,6 @@ class Product(object): title = self.warrantyDetails.productDescription or '' return title.startswith('~VIN,') - @property - def is_locked(self): - return not self.is_unlocked() - @property def parts_covered(self): return self.warrantyDetails.partCovered is True -- cgit v1.2.3