Skip to content

Comments

Converts a full dict into a more Pythonic structure. In particular ensure that all list-like structures are handled as Python lists#2

Closed
mwkuster wants to merge 4 commits intonathanwalsh:masterfrom
mwkuster:full_dict_to_list
Closed

Converts a full dict into a more Pythonic structure. In particular ensure that all list-like structures are handled as Python lists#2
mwkuster wants to merge 4 commits intonathanwalsh:masterfrom
mwkuster:full_dict_to_list

Conversation

@mwkuster
Copy link

@mwkuster mwkuster commented Apr 2, 2017

In many ways a recursive version of dict_to_list, taking a full datastructure and cleaning up any pseudo-lists found in there

#without explicit array_hook
d1 = {'a': 'b', 'c': {0: '1', 1: '2', 2: {'e': 7}, 3: {2: 8}}}
d1_cleaned = {'a': 'b', 'c': ['1', '2', {'e': 7}, {2: 8}]}
self.assertEqual(phpserialize.full_dict_to_list(d1), d1_cleaned)

#with explicit array_hook
d2 = OrderedDict({'a': 'b', 'c': OrderedDict({0: '1', 1: '2', 2: OrderedDict({'e': 7}), 3: OrderedDict({2: 8})})})
d2_cleaned = OrderedDict([('a', 'b'), ('c', ['1', '2', OrderedDict([('e', 7)]), OrderedDict([(2, 8)])])])
self.assertEqual(phpserialize.full_dict_to_list(d2, OrderedDict), d2_cleaned) 

@mwkuster
Copy link
Author

mwkuster commented Apr 2, 2017

Merged the new test with existing tests, but 14 of the existing tests fail for me with python3 (they work with python2). The added test test_full_dict_to_list works with both python2 and python3

@mwkuster mwkuster closed this Apr 2, 2017
@mwkuster mwkuster reopened this Apr 2, 2017
@mwkuster
Copy link
Author

mwkuster commented Apr 3, 2017

Should be a pull request against https://github.com/mitsuhiko/phpserialize, now recreated as
mitsuhiko#16

@mwkuster mwkuster closed this Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants