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

import os, sys


# ===========================================================================
#   Global Permutation Handling
# ===========================================================================

__permutation = None

def getPermutation():
    global __permutation
    return __permutation

def setPermutation(use):
    global __permutation
    __permutation = use



# ===========================================================================
#   Global Prefix Handling
# ===========================================================================

__prefix = None

def setPrefix(path):
    global __prefix

    if path is None:
        __prefix = None
        debug("Resetting prefix to working directory")
    else:
        __prefix = os.path.normpath(os.path.abspath(os.path.expanduser(path)))
        debug("Setting prefix to: %s" % __prefix)
    
def getPrefix():
    global __prefix
    return __prefix
    
def prependPrefix(path):
    global __prefix
    
    if __prefix and not os.path.isabs(path):
        return os.path.join(__prefix, path)
    else:
        return path



def loadLibrary(dest, path):
    class Shared(object): pass
    shared = Shared
    counter = 0

    # Method for being used as a decorator to share methods to the outside
    def share(func):
        nonlocal counter

        setattr(shared, func.__name__, func)
        counter += 1

    # Execute given file. Sharing existing global environment
    # but add additional decorator for allowing to define shared methods
    exec(open(path).read(), globals(), {"share":share})

    # Export destination name as global    
    info("Importing %s shared methods under %s...", counter, dest)
    globals()[dest] = shared



# ===========================================================================
#   Session/Core
# ===========================================================================

from jasy.core.Logging import *
from jasy.core.Error import JasyError
from jasy.env.Session import Session

# Globally available session object
session = Session()



# ===========================================================================
#   Misc Utilities
# ===========================================================================

from jasy.core.Json import *
from jasy.env.Task import task, executeTask, runTask
from jasy.env.File import *



# ===========================================================================<commit_msg>Don't use same global as environment, but clean one.<commit_after>#
# Jasy - Web Tooling Framework
# Copyright 2010-2012 Zynga Inc.
#

import os, sys


# ===========================================================================
#   Global Permutation Handling
# ===========================================================================

__permutation = None

def getPermutation():
    global __permutation
    return __permutation

def setPermutation(use):
    global __permutation
    __permutation = use



# ===========================================================================
#   Global Prefix Handling
# ===========================================================================

__prefix = None

def setPrefix(path):
    global __prefix

    if path is None:
        __prefix = None
        debug("Resetting prefix to working directory")
    else:
        __prefix = os.path.normpath(os.path.abspath(os.path.expanduser(path)))
        debug("Setting prefix to: %s" % __prefix)
    
def getPrefix():
    global __prefix
    return __prefix
    
def prependPrefix(path):
    global __prefix
    
    if __prefix and not os.path.isabs(path):
        return os.path.join(__prefix, path)
    else:
        return path




# ===========================================================================
#   Global Prefix Handling
# ===========================================================================

def loadLibrary(objectName, fileName):

    # Create internal class object for storing shared methods
    class Shared(object): pass
    exportedModule = Shared()
    counter = 0

    # Method for being used as a decorator to share methods to the outside
    def share(func):
        nonlocal counter
    
        setattr(exportedModule, func.__name__, func)
        counter += 1

    # Execute given file. Using clean new global environment
    # but add additional decorator for allowing to define shared methods
    exec(open(fileName).read(), {"share":share})

    # Export destination name as global    
    info("Importing %s shared methods under %s...", counter, objectName)
    globals()[objectName] = exportedModule



# ===========================================================================
#   Session/Core
# ===========================================================================

from jasy.core.Logging import *
from jasy.core.Error import JasyError
from jasy.env.Session import Session

# Globally available session object
session = Session()



# ===========================================================================
#   Misc Utilities
# ===========================================================================

from jasy.core.Json import *
from jasy.env.Task import task, executeTask, runTask
from jasy.env.File import *



# ===========================================================================
{'fraction_non_alphanumeric': 0.3388506602194532, 'fraction_numerical': 0.003719546215361726, 'mean_word_length': 4.432323232323232, 'pattern_counts': {'":': 2, '<': 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': '5065414', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1178, 'n_words': 373}