Beispiel #1
0
    def str_to_dict(value):
        if value is None:
            return None

        # Check for a string not conforming to the serialised format.
        if isinstance(value, basestring):
            # TODO: Check for serialised version.
            # Convert to a tuple for the next part.
            value = (value,)

        # Check if we have a tuple first, because we will convert it to a dictionary
        # and let the dictionary handler deal with it.
        if isinstance(value, tuple) and len(value) >= 1:

            # Extract our name and address.
            if len(value) >= 2:
                name = value[0]
                address = value[1]
            else:
                name = None
                address = value[0]

            # Convert to a dictionary value.
            if name:
                try:
                    value = to_address(name + ' near ' + address, geo_accuracy)
                except GoogleMapsError, urllib2.HTTPError:
                    name = None
            if not name:
                value = to_address(address, geo_accuracy)
Beispiel #2
0
    def str_to_dict(value):
        if value is None:
            return None

        # Check for a string not conforming to the serialised format.
        if isinstance(value, basestring):
            # TODO: Check for serialised version.
            # Convert to a tuple for the next part.
            value = (value, )

        # Check if we have a tuple first, because we will convert it to a dictionary
        # and let the dictionary handler deal with it.
        if isinstance(value, tuple) and len(value) >= 1:

            # Extract our name and address.
            if len(value) >= 2:
                name = value[0]
                address = value[1]
            else:
                name = None
                address = value[0]

            # Convert to a dictionary value.
            if name:
                try:
                    value = to_address(name + ' near ' + address, geo_accuracy)
                except GoogleMapsError, urllib2.HTTPError:
                    name = None
            if not name:
                value = to_address(address, geo_accuracy)