Created
January 5, 2017 20:17
-
-
Save ilovetogetspamed/5ad7ebfd8caa11d2cf2a8a606b127bca to your computer and use it in GitHub Desktop.
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
[{u'hold_maintenance_reason': u'Breaking Bits', u'id': 4}, | |
{u'hold_maintenance_reason': u'Head Down', u'id': 3}, | |
{u'hold_maintenance_reason': u'Machine will not start', u'id': 1}, | |
{u'hold_maintenance_reason': u'Making Noise', u'id': 5}, | |
{u'hold_maintenance_reason': u'No Power', u'id': 2}, | |
{u'hold_maintenance_reason': u'Panel not functioning', u'id': 6}] | |
# need to have it look like this for the spinner.values I think. | |
['Machine will not start', | |
'No Power', | |
'Head down', | |
'Breaking Bits', | |
'Making Noise', | |
'Panel not functioning'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my solution...
from pprint import pprint
from operator import itemgetter
reason_codes = [
{u'hold_maintenance_reason': u'Breaking Bits', u'id': 4},
{u'hold_maintenance_reason': u'Head Down', u'id': 3},
{u'hold_maintenance_reason': u'Machine will not start', u'id': 1},
{u'hold_maintenance_reason': u'Making Noise', u'id': 5},
{u'hold_maintenance_reason': u'No Power', u'id': 2},
{u'hold_maintenance_reason': u'Panel not functioning', 'id': 6}
]
rows_by_reason = sorted(reason_codes, key=itemgetter('hold_maintenance_reason'))
pprint(rows_by_reason)
print
rows_by_id = sorted(reason_codes, key=itemgetter('id'))
pprint(rows_by_id)
print
value_list = [u'Press here to select reason for the maintenance hold']
for reason_code in rows_by_id:
value_list.append(reason_code['hold_maintenance_reason'])
pprint(value_list)
print
value_list = tuple(item for item in value_list)
pprint(value_list)