diff options
author | Filipp Lepalaan <f@230.to> | 2013-03-30 20:11:58 +0200 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-03-30 20:11:58 +0200 |
commit | 3ce52ecbdd7cafbaadc2358a06e770a5a25b760b (patch) | |
tree | 1a4660568e5531c917bc3fb1435e22813803fc7b | |
parent | 0a590e684c8ba56ea24c439cef096ea83090172d (diff) | |
download | py-gsxws-3ce52ecbdd7cafbaadc2358a06e770a5a25b760b.tar.gz py-gsxws-3ce52ecbdd7cafbaadc2358a06e770a5a25b760b.tar.bz2 py-gsxws-3ce52ecbdd7cafbaadc2358a06e770a5a25b760b.zip |
Simplify CompTIA modifiers, add group names
-rw-r--r-- | comptia.json | 11 | ||||
-rwxr-xr-x | gsxws.py | 48 |
2 files changed, 31 insertions, 28 deletions
diff --git a/comptia.json b/comptia.json index 5be4101..92d6f1c 100644 --- a/comptia.json +++ b/comptia.json @@ -1,14 +1,4 @@ { - "modifiers": { - "A": "Not Applicable", - "B": "Continuous", - "C": "Intermittent", - "D": "Fails After Warm Up", - "E": "Environmental", - "F": "Configuration: Peripheral", - "G": "Damaged" - }, - "symptoms": { "E": { "E01": "Repairable accidental damage (OOW) - Customer Satisfaction codes", "E02": "Controls not responding (wheel-button-touch screen)", @@ -304,5 +294,4 @@ "Z21": "Bottom Case Delamination", "Z22": "Bottom Case Delamination multiple issues" } - } } @@ -209,6 +209,33 @@ class CompTIA(object): ''' Stores and accesses CompTIA codes. ''' + MODIFIERS = ( + ("A", "Not Applicable"), + ("B", "Continuous"), + ("C", "Intermittent"), + ("D", "Fails After Warm Up"), + ("E", "Environmental"), + ("F", "Configuration: Peripheral"), + ("G", "Damaged"), + ) + + GROUPS = ( + ('0', 'General'), + ('1', 'Visual'), + ('2', 'Displays'), + ('3', 'Mass Storage'), + ('4', 'Input Devices'), + ('5', 'Boards'), + ('6', 'Power'), + ('7', 'Printer'), + ('8', 'Multi-function Device'), + ('9', 'Communication Devices'), + ('A', 'Share'), + ('B', 'iPhone'), + ('E', 'iPod'), + ('F', 'iPad'), + ) + def __init__(self): df = open(os.path.join(os.path.dirname(__file__), 'comptia.json')) self.data = json.load(df) @@ -243,13 +270,9 @@ class CompTIA(object): for ci in el.findall('comptiaCodeInfo'): group[ci[0].text] = ci[1].text - self.data['symptoms'][comp_id] = group - - for el in root.findall('.//comptiaModifier'): - descr, code = list(el) - self.data['modifiers'][code.text] = descr.text + self.data[comp_id] = group - return self.data['symptoms'] + return self.data def symptoms(self, component=None): ''' @@ -257,10 +280,9 @@ class CompTIA(object): belonging to the given component code. ''' group = {} - symptoms = self.data['symptoms'] if component is None: - return symptoms + return self.data ''' Bundle the requested symptom codes as a Django-friendly @@ -269,7 +291,7 @@ class CompTIA(object): r = list() try: - group = symptoms[component] + group = self.data[component] except Exception: raise ValueError('Unknown component: %s' % component) @@ -278,14 +300,6 @@ class CompTIA(object): return r - def modifiers(self): - modifiers = list() - - for k, v in self.data['modifiers'].items(): - modifiers.append((k, v)) - - return modifiers - class GsxResponse(dict): """ This contains the data returned by a raw GSX query |