# Path: libcloud_rest/utils.py
# class LastUpdatedOrderedDict(OrderedDict):
#     """Store items in the order the keys were last added"""
# 
#     def __setitem__(self, key, value):
#         if key in self:
#             del self[key]
#         OrderedDict.__setitem__(self, key, value)


import inspect
import re
from collections import defaultdict
from itertools import takewhile
from libcloud_rest.utils import LastUpdatedOrderedDict
from libcloud_rest.errors import MethodParsingException
            return_value_types = result['return']['type_name']
            return_description = result['return']['description']
        #parse return value
        elif docstring_line.startswith('@rtype'):
            types_str = docstring_line.split(':', 1)[1]
            return_value_types = types_str.replace('\n', ' ').strip()
        #parse return description
        elif docstring_line.startswith('@return:'):
            return_description = docstring_line.split(':', 1)[1].strip()
        #parse arguments
        else:
            arg_name, update_dict = _parse_docstring_field(docstring_line)
            arguments_dict[arg_name].update(update_dict)
    #check fields
    _check_arguments_dict(arguments_dict)
    if not return_value_types:
        raise MethodParsingException('Can not get return types for method')
    return {'description': description,
            'arguments': arguments_dict,
            'return': {'description': return_description,
                       'type_name': return_value_types}}


def parse_args(method):
    args, varargs, varkw, argspec_defaults = inspect.getargspec(method)
    if inspect.ismethod(method):
        args.pop(0)
    defaults = LastUpdatedOrderedDict()
    if argspec_defaults is not None:
        defaults = dict(zip(reversed(args), reversed(argspec_defaults)))

# Path: libcloud_rest/utils.py
# class LastUpdatedOrderedDict(OrderedDict):
#     """Store items in the order the keys were last added"""
# 
#     def __setitem__(self, key, value):
#         if key in self:
#             del self[key]
#         OrderedDict.__setitem__(self, key, value)


# Path: libcloud_rest/api/parser.py
import inspect
import re
from collections import defaultdict
from itertools import takewhile
from libcloud_rest.utils import LastUpdatedOrderedDict
from libcloud_rest.errors import MethodParsingException

            return_value_types = result['return']['type_name']
            return_description = result['return']['description']
        #parse return value
        elif docstring_line.startswith('@rtype'):
            types_str = docstring_line.split(':', 1)[1]
            return_value_types = types_str.replace('\n', ' ').strip()
        #parse return description
        elif docstring_line.startswith('@return:'):
            return_description = docstring_line.split(':', 1)[1].strip()
        #parse arguments
        else:
            arg_name, update_dict = _parse_docstring_field(docstring_line)
            arguments_dict[arg_name].update(update_dict)
    #check fields
    _check_arguments_dict(arguments_dict)
    if not return_value_types:
        raise MethodParsingException('Can not get return types for method')
    return {'description': description,
            'arguments': arguments_dict,
            'return': {'description': return_description,
                       'type_name': return_value_types}}


def parse_args(method):
    args, varargs, varkw, argspec_defaults = inspect.getargspec(method)
    if inspect.ismethod(method):
        args.pop(0)
    defaults = LastUpdatedOrderedDict()
    if argspec_defaults is not None:
        defaults = dict(zip(reversed(args), reversed(argspec_defaults)))

    args_dict = LastUpdatedOrderedDict()