Retrieve values of special_cols from cols string or patch metadata

def _get_cols(special_col_names, cols, patch):
    """
    Retrieve values of special_cols from cols string or patch metadata
    """

    # If cols not given, try to fall back on cols from metadata
    if not cols:
        if 'cols' in patch.meta['Description'].keys():
            cols = patch.meta['Description']['cols']
        else:
            raise NameError, ("cols argument not given, spp_col at a minimum "
                              "must be specified")

    # Parse cols string into dict
    cols = cols.replace(' ', '')
    col_list = cols.split(';')
    col_dict = {x.split(':')[0]: x.split(':')[1] for x in col_list}

    # Get special_col_names from dict
    result = []
    for special_col_name in special_col_names:
        col_name = col_dict.get(special_col_name, None)

        # Create a count col if its requested and doesn't exist
        if special_col_name is 'count_col' and col_name is None:
            col_name = 'count'
            patch.table['count'] = np.ones(len(patch.table))

        # All special cols must be specified (count must exist by now)
        if col_name is None:
            raise ValueError, ("Required column %s not specified" %
                               special_col_name)

        result.append(col_name)

    return tuple(result), patch