<commit_before>import os

from . import parse
from . import db

PASSED = 'P' # the user has resent/forwarded/bounced this message to someone else.
REPLIED = 'R' # the user has replied to this message.
SEEN = 'S' # the user has viewed this message, though perhaps he didn't read all the way through it.
TRASHED = 'T' # the user has moved this message to the trash; the trash will be emptied by a later user action.
DRAFT = 'D' # the user considers this message a draft; toggled at user discretion.
FLAGGED = 'F' # user-defined flag; toggled at user discretion. 

def inc(maildir=None):
    '''
    1. If the message-id lookup doesn't exist, read everything in "cur" and add to the message-id lookup cache.
    2. Read everything in "new", add it to the message-id cache, and move it to "cur".
    '''
    configuration = db.read_configuration()
    if not maildir:
        maildir = configuration['maildir']

    m = db.MHDir(maildir)
    for folder in maildir.iterdir():
        if folder.name.startswith('.'):
            continue

        # Move stuff from new to cur.
        for mail in (folder / 'new').iterdir():
            if ':' in mail.name:
                newname = mail.name
            else:
                newname = mail.name + ':2,'
            mail.rename(folder / 'cur' / newname)

        # Index the stuff in cur.
        for mail in (folder / 'cur').iterdir():
            if str(mail) not in m.path_messageid:
                with mail.open('rb') as fp:
                    message_id = parse.message_id(fp)
                m.messageid_path[message_id] = str(mail)
                m.path_messageid[str(mail)] = message_id<commit_msg>types<commit_after>import os

from pathlib import Path

from . import parse
from . import db

PASSED = 'P' # the user has resent/forwarded/bounced this message to someone else.
REPLIED = 'R' # the user has replied to this message.
SEEN = 'S' # the user has viewed this message, though perhaps he didn't read all the way through it.
TRASHED = 'T' # the user has moved this message to the trash; the trash will be emptied by a later user action.
DRAFT = 'D' # the user considers this message a draft; toggled at user discretion.
FLAGGED = 'F' # user-defined flag; toggled at user discretion. 

def inc(maildir=None):
    '''
    1. If the message-id lookup doesn't exist, read everything in "cur" and add to the message-id lookup cache.
    2. Read everything in "new", add it to the message-id cache, and move it to "cur".
    '''
    configuration = db.read_configuration()
    if not maildir:
        maildir = configuration['maildir']

    m = db.MHDir(maildir)
    for folder in Path(maildir).iterdir():
        if folder.name.startswith('.'):
            continue

        # Move stuff from new to cur.
        for mail in (folder / 'new').iterdir():
            if ':' in mail.name:
                newname = mail.name
            else:
                newname = mail.name + ':2,'
            mail.rename(folder / 'cur' / newname)

        # Index the stuff in cur.
        for mail in (folder / 'cur').iterdir():
            if str(mail) not in m.path_messageid:
                with mail.open('rb') as fp:
                    message_id = parse.message_id(fp)
                m.messageid_path[message_id] = str(mail)
                m.path_messageid[str(mail)] = message_id
{'fraction_non_alphanumeric': 0.10011990407673861, 'fraction_numerical': 0.0017985611510791368, 'mean_word_length': 2.2715686274509803, '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': '2795150', 'n_tokens_mistral': 996, 'n_tokens_neox': 969, 'n_words': 379}