Ignore:
Timestamp:
04/22/06 17:08:32 (8 years ago)
Author:
xi
Message:

Sort object attributes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyyaml/trunk/lib/yaml/representer.py

    r147 r148  
    242242        else: 
    243243            state = data.__dict__.copy() 
     244        if isinstance(state, dict): 
     245            state = state.items() 
     246            state.sort() 
    244247        return self.represent_mapping(tag, state, flow_style=flow_style) 
    245248 
     
    373376            state = data.__dict__ 
    374377        if args is None and isinstance(state, dict): 
     378            state = state.items() 
     379            state.sort() 
    375380            return self.represent_mapping( 
    376381                    u'tag:yaml.org,2002:python/object:'+class_name, state) 
     
    431436        if not args and not listitems and not dictitems \ 
    432437                and isinstance(state, dict) and newobj: 
     438            state = state.items() 
     439            state.sort() 
    433440            return self.represent_mapping( 
    434441                    u'tag:yaml.org,2002:python/object:'+function_name, state) 
Note: See TracChangeset for help on using the changeset viewer.