# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def nativestr(x):
#     return x if isinstance(x, str) else x.decode('utf-8', 'replace')


from aredis.exceptions import RedisError
from aredis.utils import b, nativestr
                                            count=count, sort=sort, store=store,
                                            store_dist=store_dist)

    async def georadiusbymember(self, name, member, radius, unit=None,
                                withdist=False, withcoord=False, withhash=False,
                                count=None, sort=None, store=None, store_dist=None):
        """
        This command is exactly like ``georadius`` with the sole difference
        that instead of taking, as the center of the area to query, a longitude
        and latitude value, it takes the name of a member already existing
        inside the geospatial index represented by the sorted set.
        """
        return await self._georadiusgeneric('GEORADIUSBYMEMBER',
                                            name, member, radius, unit=unit,
                                            withdist=withdist, withcoord=withcoord,
                                            withhash=withhash, count=count,
                                            sort=sort, store=store,
                                            store_dist=store_dist)

    async def _georadiusgeneric(self, command, *args, **kwargs):
        pieces = list(args)
        if kwargs['unit'] and kwargs['unit'] not in ('m', 'km', 'mi', 'ft'):
            raise RedisError("GEORADIUS invalid unit")
        elif kwargs['unit']:
            pieces.append(kwargs['unit'])
        else:
            pieces.append('m', )

        for token in ('withdist', 'withcoord', 'withhash'):
            if kwargs[token]:

# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def nativestr(x):
#     return x if isinstance(x, str) else x.decode('utf-8', 'replace')


# Path: aredis/commands/geo.py
from aredis.exceptions import RedisError
from aredis.utils import b, nativestr

                                            count=count, sort=sort, store=store,
                                            store_dist=store_dist)

    async def georadiusbymember(self, name, member, radius, unit=None,
                                withdist=False, withcoord=False, withhash=False,
                                count=None, sort=None, store=None, store_dist=None):
        """
        This command is exactly like ``georadius`` with the sole difference
        that instead of taking, as the center of the area to query, a longitude
        and latitude value, it takes the name of a member already existing
        inside the geospatial index represented by the sorted set.
        """
        return await self._georadiusgeneric('GEORADIUSBYMEMBER',
                                            name, member, radius, unit=unit,
                                            withdist=withdist, withcoord=withcoord,
                                            withhash=withhash, count=count,
                                            sort=sort, store=store,
                                            store_dist=store_dist)

    async def _georadiusgeneric(self, command, *args, **kwargs):
        pieces = list(args)
        if kwargs['unit'] and kwargs['unit'] not in ('m', 'km', 'mi', 'ft'):
            raise RedisError("GEORADIUS invalid unit")
        elif kwargs['unit']:
            pieces.append(kwargs['unit'])
        else:
            pieces.append('m', )

        for token in ('withdist', 'withcoord', 'withhash'):
            if kwargs[token]:

                pieces.append(b(token.upper()))