<commit_before>#
# Jasy - Web Tooling Framework
# Copyright 2010-2012 Zynga Inc.
#

import itertools, time, atexit, json, os

from jasy.i18n.Translation import Translation
from jasy.i18n.LocaleData import *

from jasy.core.Json import toJson
from jasy.core.Project import Project, getProjectFromPath, getProjectDependencies
from jasy.core.Permutation import Permutation

from jasy.core.Error import JasyError
from jasy.env.State import setPermutation, header
from jasy.core.Json import toJson
from jasy.core.Logging import *

__all__ = ["Session"]


class Session():
    #
    # Core
    #

    def __init__(self):
        atexit.register(self.close)

        self.__timestamp = time.time()
        self.__projects = []
        self.__projectByName = {}
        self.__fields = {}
        
        header("Initializing project")

        try:
            self.addProject(getProjectFromPath("."))
        except JasyError as err:
            outdent(True)
            error(err)
            raise JasyError("Critical: Could not initialize session!")
    
    
    def clean(self):
        """Clears all caches of known projects"""

        header("Cleaning session...")<commit_msg>Only init first project from session when there is an actual project in the current folder<commit_after>#
# Jasy - Web Tooling Framework
# Copyright 2010-2012 Zynga Inc.
#

import itertools, time, atexit, json, os

from jasy.i18n.Translation import Translation
from jasy.i18n.LocaleData import *

from jasy.core.Json import toJson
from jasy.core.Project import Project, getProjectFromPath, getProjectDependencies
from jasy.core.Permutation import Permutation
from jasy.core.Config import findConfig

from jasy.core.Error import JasyError
from jasy.env.State import setPermutation, header
from jasy.core.Json import toJson
from jasy.core.Logging import *

__all__ = ["Session"]


class Session():
    #
    # Core
    #

    def __init__(self):
        atexit.register(self.close)

        self.__timestamp = time.time()
        self.__projects = []
        self.__projectByName = {}
        self.__fields = {}
        
        if findConfig("jasyproject"):

            header("Initializing project")

            try:
                self.addProject(getProjectFromPath("."))
            except JasyError as err:
                outdent(True)
                error(err)
                raise JasyError("Critical: Could not initialize session!")
    
    
    def clean(self):
        """Clears all caches of known projects"""

        header("Cleaning session...")
{'fraction_non_alphanumeric': 0.09080188679245282, 'fraction_numerical': 0.009433962264150943, 'mean_word_length': 2.6513629842180775, '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': '1026790', 'n_tokens_mistral': 766, 'n_tokens_neox': 712, 'n_words': 202}