<commit_before># coding=utf-8

"""
This module provides functions for working with and resolving data from a CSV file.
"""

import os
import csv
import itertools

from cards.templatefield import TemplateField, fields
from cards.markdown import markdown

from cards.util import FileWrapper, lower_first_row
from cards.warning import WarningDisplay, WarningContext
from cards.constants import Columns, ColumnDescriptors


class Column:
    """ Represents a column in a datasource. """

    def __init__(self, name: str, content: str=None):
        self.name = name
        self.content = content

    def is_excluded(self) -> bool:
        """ Determine whether the column should be excluded. """

        return (self.name.startswith('(') and self.name.endswith(')')
                if self.name is not None
                else False)

    def is_special(self) -> bool:
        """ Determine whether the column is to be treated as a special column. """

        return (self.name.startswith('@')
                if self.name is not None
                else False)

    def is_back_only(self) -> bool:
        """ Determine whether the column is only intended for the back of a card. """

        return (self.name.endswith(ColumnDescriptors.BACK_ONLY)
                if self.name is not None
                else False)


class Row:
    """ Represents a row in a datasource. """

    def __init__(self,
                 data: dict,
                 data_path: str=None,
                 row_index: int=None,
                 is_excluded: bool=False):
        self.data = data
        self.data_path = data_path
        self.row_index = row_index
        self.is_excluded = is_excluded

    def _usable_columns(self) -> tuple:
        return (column for column in
                (Column(name, content) for name, content in self.data.items())
                if not column.is_excluded()
                and not column.is_special())

    def _front_data(self) -> dict:
        """ Return a dict containing only items fit for the front of a card. """<commit_msg>Remove type hint<commit_after># coding=utf-8

"""
This module provides functions for working with and resolving data from a CSV file.
"""

import os
import csv
import itertools

from cards.templatefield import TemplateField, fields
from cards.markdown import markdown

from cards.util import FileWrapper, lower_first_row
from cards.warning import WarningDisplay, WarningContext
from cards.constants import Columns, ColumnDescriptors


class Column:
    """ Represents a column in a datasource. """

    def __init__(self, name: str, content: str=None):
        self.name = name
        self.content = content

    def is_excluded(self) -> bool:
        """ Determine whether the column should be excluded. """

        return (self.name.startswith('(') and self.name.endswith(')')
                if self.name is not None
                else False)

    def is_special(self) -> bool:
        """ Determine whether the column is to be treated as a special column. """

        return (self.name.startswith('@')
                if self.name is not None
                else False)

    def is_back_only(self) -> bool:
        """ Determine whether the column is only intended for the back of a card. """

        return (self.name.endswith(ColumnDescriptors.BACK_ONLY)
                if self.name is not None
                else False)


class Row:
    """ Represents a row in a datasource. """

    def __init__(self,
                 data: dict,
                 data_path: str=None,
                 row_index: int=None,
                 is_excluded: bool=False):
        self.data = data
        self.data_path = data_path
        self.row_index = row_index
        self.is_excluded = is_excluded

    def _usable_columns(self):
        return (column for column in
                (Column(name, content) for name, content in self.data.items())
                if not column.is_excluded()
                and not column.is_special())

    def _front_data(self) -> dict:
        """ Return a dict containing only items fit for the front of a card. """
{'fraction_non_alphanumeric': 0.08600583090379009, 'fraction_numerical': 0.00048590864917395527, 'mean_word_length': 2.2214397496087637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '6138388', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1081, 'n_words': 395}