On Wed, Dec 12, 2018 at 10:57 AM yann19 <[email protected]> wrote:

> My bad, had thought I had added in my dictionary example.
> Here you go - https://pastebin.com/raw/wb9gw3L9
>
> And my actual codes:
> from datetime import datetime
>
> def sortedPage(d):
>     return {k: {'elements': sorted([v1 for k1 ,v1 in
> v['elements'].items()], key=lambda el:
> datetime.strptime(el['data']['created'], '%d/%m/%y %H:%M'))} for k,v in
> d.items()}
>
> output = {k: sortedPage(v) if k == 'pages' else v for k,v in
> test_dict.items()}
> pprint(output)
>
> I am trying to retain the whole contents of the dictionary to begin with
> but with sorting options based on a particular key/value.
> However I just noticed that in the code, I am missing the unique ids..
>
> Example - The output of returned code:
> {'page_order': ['rotatingTest', 'zoomingTest', 'panningTest'],
>  'pages': {'panningTest': {'elements': [{'data': {'created': '04/10/18
> 12:43',
>                                                   'description': 'panning
> test for posZ',
>                                                   'name':
> 'posePan_positionZ_v001',
>                                                   'project': 'TEST',
>                                                   'version': '1'},
>                                          'name': 'posePan_positionZ_v001',
>                                          'thumbnail':
> '/user_data/posePan_positionZ_v001/posePan_positionZ_v001.thumb.jpg',
>                                          'type': 'PosedWidget',
>                                          'uid': '7lyuri8g8u5ctwsa'}]},
>
> Whereas what I am trying to achieve:
> {'page_order': ['rotatingTest', 'zoomingTest', 'panningTest'],
>  'pages': {'panningTest': {'elements': {'7lyuri8g8u5ctwsa' : [{'data':
> {'created': '04/10/18 12:43',
>                                                   'description': 'panning
> test for posZ',
>                                                   'name':
> 'posePan_positionZ_v001',
>                                                   'project': 'TEST',
>                                                   'version': '1'},
>                                          'name': 'posePan_positionZ_v001',
>                                          'thumbnail':
> '/user_data/posePan_positionZ_v001/posePan_positionZ_v001.thumb.jpg',
>                                          'type': 'PosedWidget',
>                                          'uid': '7lyuri8g8u5ctwsa'}]}}
>
> Noticed that the '7lyuri8g8u5ctwsa' is missing as part of the key after
> "elements"
>

What is the reasoning to want  {uid: [element]}  when its always going to
be a single item list of the element for that uid key?


> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/6b3f5f28-8898-4570-9448-36b07a405005%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/6b3f5f28-8898-4570-9448-36b07a405005%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2qJATWQhsF-r0LPvqF8wKx-8a8%3DTyDLFm91VBtf6f1mQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to