# Path: ripozo/exceptions.py
# class RestException(Exception):
#     """
#     The base exception for any of the package
#     specific exceptions
#     """
#     def __init__(self, message=None, status_code=500, *args, **kwargs):
#         super(RestException, self).__init__(message, *args, **kwargs)
#         self.status_code = status_code
# 
# Path: ripozo/utilities.py
# def get_or_pop(dictionary, key, default=None, pop=False):
#     """A simple helper for getting or popping a property
#     from a dictionary depending on the ```pop``` parameter.
# 
#     This is a helper method for relationships to easily
#     update whether they keep or remove items from
#     the parent
# 
#     :param dict dictionary: The dictionary to check
#     :param object key: The key to look for in the dictionary
#     :param object default: The default value to return if nothing
#         is found
#     :param bool pop: A boolean that removes the item from
#         the dictionary if true.  Otherwise it just gets
#         the value from the dictionary
#     :returns: The value of the requested object or the
#         default if it was not found.
#     :rtype: object
#     """
#     if pop:
#         return dictionary.pop(key, default)
#     return dictionary.get(key, default)


from ripozo.exceptions import RestException
from ripozo.resources.constructor import ResourceMetaClass
from ripozo.utilities import get_or_pop
import logging
import six
        for key in six.iterkeys(self.property_map):
            properties.pop(key, None)
        properties.pop(self.name, None)
        return properties

    def _map_pks(self, parent_properties):
        """
        Takes a dictionary of the values of the parent
        resources properties.  It then maps those properties
        to the named properties of the related resource
        and creates a dictionary of the related resources
        property values.  Raises a KeyError if the parent
        does not contain keys that matches every key in
        the self.property_map

        :param dict parent_properties: A dictionary of the parent
            resource's properties.  The key is the name of the
            property and the value is the parent resources value
            for that property
        :return: A dictionary of the related resources properties.
            The key is the name of the related resource's property
            and the value is the value of that resource's property.
        :rtype: :py:class:`dict`
        :raises: KeyError
        """
        properties = {}
        for parent_prop, prop in six.iteritems(self.property_map):
            val = get_or_pop(parent_properties, parent_prop, pop=self.remove_properties)
            if val is not None:
                properties[prop] = val

# Path: ripozo/exceptions.py
# class RestException(Exception):
#     """
#     The base exception for any of the package
#     specific exceptions
#     """
#     def __init__(self, message=None, status_code=500, *args, **kwargs):
#         super(RestException, self).__init__(message, *args, **kwargs)
#         self.status_code = status_code
# 
# Path: ripozo/utilities.py
# def get_or_pop(dictionary, key, default=None, pop=False):
#     """A simple helper for getting or popping a property
#     from a dictionary depending on the ```pop``` parameter.
# 
#     This is a helper method for relationships to easily
#     update whether they keep or remove items from
#     the parent
# 
#     :param dict dictionary: The dictionary to check
#     :param object key: The key to look for in the dictionary
#     :param object default: The default value to return if nothing
#         is found
#     :param bool pop: A boolean that removes the item from
#         the dictionary if true.  Otherwise it just gets
#         the value from the dictionary
#     :returns: The value of the requested object or the
#         default if it was not found.
#     :rtype: object
#     """
#     if pop:
#         return dictionary.pop(key, default)
#     return dictionary.get(key, default)


# Path: ripozo/resources/relationships/relationship.py
from ripozo.exceptions import RestException
from ripozo.resources.constructor import ResourceMetaClass
from ripozo.utilities import get_or_pop
import logging
import six

        for key in six.iterkeys(self.property_map):
            properties.pop(key, None)
        properties.pop(self.name, None)
        return properties

    def _map_pks(self, parent_properties):
        """
        Takes a dictionary of the values of the parent
        resources properties.  It then maps those properties
        to the named properties of the related resource
        and creates a dictionary of the related resources
        property values.  Raises a KeyError if the parent
        does not contain keys that matches every key in
        the self.property_map

        :param dict parent_properties: A dictionary of the parent
            resource's properties.  The key is the name of the
            property and the value is the parent resources value
            for that property
        :return: A dictionary of the related resources properties.
            The key is the name of the related resource's property
            and the value is the value of that resource's property.
        :rtype: :py:class:`dict`
        :raises: KeyError
        """
        properties = {}
        for parent_prop, prop in six.iteritems(self.property_map):
            val = get_or_pop(parent_properties, parent_prop, pop=self.remove_properties)
            if val is not None:
                properties[prop] = val

        name_values = get_or_pop(parent_properties, self.name, pop=self.remove_properties)