human
Complete the below
def get_ordered_locations(locations, uri_key='url', **kwargs):

    ''''Order image location list.
    :param locations: The original image location list.
    :param uri_key: The key name for location URI in image location dictionary.
    :returns: The image location list with preferred store type order.'
    '''
 ... Give me a the Python code you requested?
assistant
#Here is the Python code you requested.
    def _foreach_store_type_preference():
        store_types = CONF.store_type_location_strategy.store_type_preference
        for preferred_store in store_types:
            preferred_store = str(preferred_store).strip()
            if (not preferred_store):
                continue
            (yield preferred_store)
    if (not locations):
        return locations
    preferences = {}
    others = []
    for preferred_store in _foreach_store_type_preference():
        preferences[preferred_store] = []
    for location in locations:
        uri = location.get(uri_key)
        if (not uri):
            continue
        pieces = urlparse.urlparse(uri.strip())
        store_name = None
        for (store, schemes) in six.iteritems(_STORE_TO_SCHEME_MAP):
            if (pieces.scheme.strip() in schemes):
                store_name = store
                break
        if (store_name in preferences):
            preferences[store_name].append(location)
        else:
            others.append(location)
    ret = []
    for preferred_store in _foreach_store_type_preference():
        ret.extend(preferences[preferred_store])
    ret.extend(others)
    return ret