<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _tilequeue_rawr_setup(cfg):
 """command to read from rawr queue and generate rawr tiles"""

    rawr_yaml = cfg.yml.get('rawr')
    assert rawr_yaml is not None, 'Missing rawr configuration in yaml'

    rawr_postgresql_yaml = rawr_yaml.get('postgresql')
    assert rawr_postgresql_yaml, 'Missing rawr postgresql config'

    from raw_tiles.formatter.msgpack import Msgpack
    from raw_tiles.gen import RawrGenerator
    from raw_tiles.source.conn import ConnectionContextManager
    from raw_tiles.source import parse_sources
    from raw_tiles.source import DEFAULT_SOURCES as DEFAULT_RAWR_SOURCES
    from tilequeue.rawr import RawrS3Sink
    from tilequeue.rawr import RawrStoreSink
    import boto3
    # pass through the postgresql yaml config directly
    conn_ctx = ConnectionContextManager(rawr_postgresql_yaml)

    rawr_source_list = rawr_yaml.get('sources', DEFAULT_RAWR_SOURCES)
    assert isinstance(rawr_source_list, list), \
        'RAWR source list should be a list'
    assert len(rawr_source_list) > 0, \
        'RAWR source list should be non-empty'

    rawr_store = rawr_yaml.get('store')
    if rawr_store:
        store = make_store(
            rawr_store, credentials=cfg.subtree('aws credentials'))
        rawr_sink = RawrStoreSink(store)

    else:
        rawr_sink_yaml = rawr_yaml.get('sink')
        assert rawr_sink_yaml, 'Missing rawr sink config'
        sink_type = rawr_sink_yaml.get('type')
        assert sink_type, 'Missing rawr sink type'
        if sink_type == 's3':
            s3_cfg = rawr_sink_yaml.get('s3')
            assert s3_cfg, 'Missing s3 config'
            bucket = s3_cfg.get('bucket')
            assert bucket, 'Missing rawr sink bucket'
            sink_region = s3_cfg.get('region')
            assert sink_region, 'Missing rawr sink region'
            prefix = s3_cfg.get('prefix')
            assert prefix, 'Missing rawr sink prefix'
            extension = s3_cfg.get('extension')
            assert extension, 'Missing rawr sink extension'
            tags = s3_cfg.get('tags')
            from tilequeue.store import make_s3_tile_key_generator
            tile_key_gen = make_s3_tile_key_generator(s3_cfg)

            s3_client = boto3.client('s3', region_name=sink_region)
            rawr_sink = RawrS3Sink(
                s3_client, bucket, prefix, extension, tile_key_gen, tags)
        elif sink_type == 'none':
            from tilequeue.rawr import RawrNullSink
            rawr_sink = RawrNullSink()
        else:
            assert 0, 'Unknown rawr sink type %s' % sink_type

    rawr_source = parse_sources(rawr_source_list)
    rawr_formatter = Msgpack()
    rawr_gen = RawrGenerator(rawr_source, rawr_formatter, rawr_sink)

    return rawr_gen, conn_ctx