<commit_before>from app.model.pgadapter import PgAdapter


class BaseMapper:
    def __init__(self):
        self._db = PgAdapter()

    def format_rows(self, rows, fields):
        if rows is None or fields is None:
            raise ValueError('Invalid argument')
        if not isinstance(fields, list):
            raise ValueError('Invalid data type. arg:fields_list')
        rows = [{f: row[f] for f in fields} for row in rows]
        return rows<commit_msg>implement format row<commit_after>from app.model.pgadapter import PgAdapter


class BaseMapper:
    def __init__(self):
        self._db = PgAdapter()

    def format_rows(self, rows, fields):
        if rows is None or fields is None:
            raise ValueError('Invalid argument')
        if not isinstance(fields, list):
            raise ValueError('Invalid data type. arg:fields_list')
        rows = [{f: row[f] for f in fields} for row in rows]
        return rows

    def format_row(self, row, fields):
        if row is None or fields is None:
            raise ValueError('Invalid argumant')
        if not isinstance(fields, (tuple, list)):
            raise ValueError('Invalid data type')
        return {f: row[f] for f in fields}
{'fraction_non_alphanumeric': 0.08903544929925804, 'fraction_numerical': 0.0, 'mean_word_length': 2.560117302052786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '221378', 'n_tokens_mistral': 329, 'n_tokens_neox': 330, 'n_words': 126}