ValvePython / vdf

📜 Package for working with Valve's text and binary KeyValue format
https://pypi.org/project/vdf/
MIT License
167 stars 31 forks source link

Added DuplicateOrderedDict #6

Closed SleepProgger closed 8 years ago

SleepProgger commented 8 years ago

I added your DuplicateOrderedDict implementation as referenced in #5 , and some test cases. Also, i made the usage feel a bit more like a "real" dict.

If you don't like my changes please tell me what to change. IMHO, the vdf lib really need something like this build in asap.

rossengeorgiev commented 8 years ago

If we are to ship this we need to implement all the methods from https://docs.python.org/3/library/stdtypes.html#mapping-types-dict

Should be compatible with py2 and py3. For example, in py3 .values() returns a list, while in py3 you get a iterator. To get a iterator in py2 you need .itervalues(). It would be nice adhere to that API.

All that with the order/duplicates in mind, of course. At a glance it seems that it might not be the case currently.

May as well consider calling it VDFDict or something else as it's specific to VDF, rather than a generic solution. For example, one of the underline assumptions is that keys can only be a str or tuple.

Finally, might as well throw the code for it in a separate file as this is __init__ is getting long.

SleepProgger commented 8 years ago

I refactored the code a bit. It should now be compatible with py2 and 3. Also moved the class to its own file. Let me know what you think.

edit: We should def squash my fail series if you accept this pull request. (Sorry for the mess)

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.7%) to 99.346% when pulling 448a357ae5dcc3e6881bf4cbf277cc62bd101a8c on SleepProgger:duplicate_dict into 8e50d5a079cf2d02f48f9fc89c4f76d5108b2cc5 on ValvePython:master.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-4.2%) to 95.806% when pulling 14d84fed78b45ed7284c8e85a30111c3cdf2fda3 on SleepProgger:duplicate_dict into 8e50d5a079cf2d02f48f9fc89c4f76d5108b2cc5 on ValvePython:master.

rossengeorgiev commented 8 years ago

Hi, I've pulled your code and reworked it. See #8