<commit_before># encoding=utf-8

import os, lzma
import shutil
import zipfile

from sqlalchemy import func

from terroroftinytown.format import registry
from terroroftinytown.format.projectsettings import ProjectSettingsWriter
from terroroftinytown.format.urlformat import quote
from terroroftinytown.tracker.bootstrap import Bootstrap
from terroroftinytown.tracker.model import new_session, Project, Result


class Exporter:
    projects_count = 0
    items_count = 0
    last_date = None

    output_dir = ''
    settings = {}

    lzma = True
    extension = 'txt.xz'

    # Length of directory name
    dir_length = 2
    # Number of characters from the right are not used in directory name
    # in other words, number of _
    max_right = 4
    # Number of characters from the left that are used in file name
    # in other words, number of characters that are not in directory name and not _
    file_length = 2

    # Example of settings:
    # dir_length = 2
    # max_right = 4
    # file_length = 2
    # output: projectname/00/01/000100____.txt, projectname/01/01__.txt

    after = None

    def __init__(self, output_dir, format="beacon", settings={}):
        super().__init__()
        self.setup_format(format)
        self.output_dir = output_dir
        self.settings = settings
        self.after = self.settings['after']

    def setup_format(self, format):
        self.format = registry[format]

    def make_output_dir(self):
        if not os.path.isdir(self.output_dir):
            os.makedirs(self.output_dir)

    def dump(self):
        self.make_output_dir()
<commit_msg>tracker.export: Use instance instead of class variables to avoid clobbering<commit_after># encoding=utf-8

import os, lzma
import shutil
import zipfile

from sqlalchemy import func

from terroroftinytown.format import registry
from terroroftinytown.format.projectsettings import ProjectSettingsWriter
from terroroftinytown.format.urlformat import quote
from terroroftinytown.tracker.bootstrap import Bootstrap
from terroroftinytown.tracker.model import new_session, Project, Result


class Exporter:
    def __init__(self, output_dir, format="beacon", settings={}):
        super().__init__()

        self.setup_format(format)
        self.output_dir = output_dir
        self.settings = settings
        self.after = self.settings['after']

        self.projects_count = 0
        self.items_count = 0
        self.last_date = None

        self.lzma = True
        self.extension = 'txt.xz'

        # Length of directory name
        self.dir_length = 2
        # Number of characters from the right are not used in directory name
        # in other words, number of _
        self.max_right = 4
        # Number of characters from the left that are used in file name
        # in other words, number of characters that are not in directory name and not _
        self.file_length = 2

        # Example of settings:
        # dir_length = 2
        # max_right = 4
        # file_length = 2
        # output: projectname/00/01/000100____.txt, projectname/01/01__.txt

    def setup_format(self, format):
        self.format = registry[format]

    def make_output_dir(self):
        if not os.path.isdir(self.output_dir):
            os.makedirs(self.output_dir)

    def dump(self):
        self.make_output_dir()

{'fraction_non_alphanumeric': 0.07314870559903673, 'fraction_numerical': 0.013847080072245636, 'mean_word_length': 2.859465737514518, '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': '1061728', 'n_tokens_mistral': 999, 'n_tokens_neox': 951, 'n_words': 291}