<commit_before># Copyright (c) 2016, <NAME>
# Released subject to the New BSD License
# Please see http://en.wikipedia.org/wiki/BSD_licenses

import re
import smtplib
import imaplib
from email import message_from_string
from active_mail_filter import get_logger, trace

logger = get_logger()
MAX_FETCH_HEADERS = 2048


class MboxFolder(object):
    def __init__(self, host, username, password):
        self.host = host
        self.username = username
        self.password = password
        self.imap = None
        self.connect()

    def __str__(self):
        return 'MboxFolder [host=' + self.host + ', username=' + self.username + \
               ', imap=' + str(self.imap) + ']'

    def connect(self):
        if self.imap is None:
            logger.debug('imap connecting to host %s:%d' % (self.host, imaplib.IMAP4_SSL_PORT))
            try:
                self.imap = imaplib.IMAP4_SSL(self.host, port=imaplib.IMAP4_SSL_PORT)
                self.imap.login(self.username, self.password)
            except Exception as e:
                logger.error('connection failure, %s.', str(e.message))
                raise e

    def disconnect(self):
        if self.imap is not None:
            logger.debug('imap disconnecting from host %s' % self.host)
            self.imap.logout()
            del self.imap
            self.imap = None

    def list_folders(self):
        folder_list = []
        result, folders = self.imap.list()
        for f in folders:
            fields = f.split('"')
            folder = fields[-2] if 'inbox' != fields[-2].lower() else fields[-2].lower()
            folder_list.append(folder)
        return folder_list

    def list_folder_counts(self):
        folders = self.list_folders()
        folder_dict = {}
        for f in folders:
            uids = self.list_email_uids(folder_name=f)
            folder_dict[f] = len(uids) > 0<commit_msg>ignore noselect folders<commit_after># Copyright (c) 2016, <NAME>
# Released subject to the New BSD License
# Please see http://en.wikipedia.org/wiki/BSD_licenses

import re
import smtplib
import imaplib
from email import message_from_string
from active_mail_filter import get_logger, trace

logger = get_logger()
MAX_FETCH_HEADERS = 2048


class MboxFolder(object):
    def __init__(self, host, username, password):
        self.host = host
        self.username = username
        self.password = password
        self.imap = None
        self.connect()

    def __str__(self):
        return 'MboxFolder [host=' + self.host + ', username=' + self.username + \
               ', imap=' + str(self.imap) + ']'

    def connect(self):
        if self.imap is None:
            logger.debug('imap connecting to host %s:%d' % (self.host, imaplib.IMAP4_SSL_PORT))
            try:
                self.imap = imaplib.IMAP4_SSL(self.host, port=imaplib.IMAP4_SSL_PORT)
                self.imap.login(self.username, self.password)
            except Exception as e:
                logger.error('connection failure, %s.', str(e.message))
                raise e

    def disconnect(self):
        if self.imap is not None:
            logger.debug('imap disconnecting from host %s' % self.host)
            self.imap.logout()
            del self.imap
            self.imap = None

    def list_folders(self):
        folder_list = []
        result, folders = self.imap.list()
        for f in folders:
            fields = f.split('"')
            if '\\noselect' not in fields[0].lower():
                folder = fields[-2] if 'inbox' != fields[-2].lower() else fields[-2].lower()
                folder_list.append(folder)
        return folder_list

    def list_folder_counts(self):
        folders = self.list_folders()
        folder_dict = {}
        for f in folders:
            uids = self.list_email_uids(folder_name=f)
            folder_dict[f] = len(uids) > 0
{'fraction_non_alphanumeric': 0.10956072351421188, 'fraction_numerical': 0.008010335917312662, 'mean_word_length': 2.1445978878960195, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4017929', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1167, 'n_words': 292}