<commit_before>#!/usr/bin/env python3

# Extend PYTHONPATH with 'lib'
import sys, os, traceback
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), os.pardir, "lib")))

# Import JavaScript tooling
from js import *

# Application specific code
session = Session()
session.addProject(Project("../../qooxdoo/qooxdoo/framework"))
session.addProject(Project("../../qooxdoo/qooxdoo/component/apiviewer"))
session.addProject(Project("../../unify/framework"))

# Locale data
session.addLocale("en_US")

# Variant data
session.addVariant("qx.debug", [ '"on"' ])
session.addVariant("qx.client", [ '"gecko"' ])
session.addVariant("qx.dynlocale", [ '"off"' ])
session.addVariant("qx.globalErrorHandling", [ '"off"' ])
session.addVariant("qx.version", ["1.0"])
session.addVariant("qx.theme", ['"apiviewer.Theme"'])

# Create optimizer for improved speed/compression
optimization = Optimization(["unused", "privates", "variables", "declarations", "blocks"])

# Process every possible permutation
try:
    for permutation in session.getPermutations():
        logging.info("PERMUTATION: %s" % permutation)
    
        # Resolving dependencies
        resolver = Resolver(session, permutation)
        resolver.addClassName("apiviewer.Application")
        resolver.addClassName("apiviewer.Theme")
        classes = resolver.getIncludedClasses()
    
        # Collect Resources
        resources = Resources(session, classes, permutation)
        resourceCode = resources.export()    

        # Sorting classes
        sorter = Sorter(classes, permutation)
        sortedClasses = sorter.getSortedClasses()
    
        # Compiling classes
        compressor = Compressor(sortedClasses, permutation, optimization)
        compressed = compressor.compress()

        # Combine result
        buildCode = resourceCode + compressed + "qx.core.Init.boot(apiviewer.Application);"

        # Create filename
        # Based on permutation.getKey(), optimization, modification date, etc.
        outfileName = "build.js"

        # Write file
        outfile = open(outfileName, mode="w", encoding="utf-8")
        outfile.write(buildCode)
        outfile.close()

except BaseException as ex:
    logging.error(ex)
    traceback.print_exc()
    

# Close session
session.close()<commit_msg>Moved more code into try-except block.<commit_after>#!/usr/bin/env python3

# Extend PYTHONPATH with 'lib'
import sys, os, traceback
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), os.pardir, "lib")))

# Import JavaScript tooling
from js import *

# Open Session
session = Session()

# Protect session
try:
    # Application specific code
    session.addProject(Project("../../qooxdoo/qooxdoo/framework"))
    session.addProject(Project("../../qooxdoo/qooxdoo/component/apiviewer"))
    session.addProject(Project("../../unify/framework"))

    # Locale data
    session.addLocale("en_US")

    # Variant data
    session.addVariant("qx.debug", [ '"on"' ])
    session.addVariant("qx.client", [ '"gecko"' ])
    session.addVariant("qx.dynlocale", [ '"off"' ])
    session.addVariant("qx.globalErrorHandling", [ '"off"' ])
    session.addVariant("qx.version", ["1.0"])
    session.addVariant("qx.theme", ['"apiviewer.Theme"'])

    # Create optimizer for improved speed/compression
    optimization = Optimization(["unused", "privates", "variables", "declarations", "blocks"])
    
    # Process every possible permutation
    for permutation in session.getPermutations():
        logging.info("PERMUTATION: %s" % permutation)
    
        # Resolving dependencies
        resolver = Resolver(session, permutation)
        resolver.addClassName("apiviewer.Application")
        resolver.addClassName("apiviewer.Theme")
        classes = resolver.getIncludedClasses()

        # Collect Resources
        resources = Resources(session, classes, permutation)
        resourceCode = resources.export()    

        # Sorting classes
        sorter = Sorter(resolver, permutation)
        sortedClasses = sorter.getSortedClasses()

        # Compiling classes
        compressor = Compressor(sortedClasses, permutation, optimization)
        compressed = compressor.compress()

        # Combine result
        buildCode = resourceCode + compressed + "qx.core.Init.boot(apiviewer.Application);"

        # Create filename
        # Based on permutation.getKey(), optimization, modification date, etc.
        outfileName = "build.js"

        # Write file
        outfile = open(outfileName, mode="w", encoding="utf-8")
        outfile.write(buildCode)
        outfile.close()

except BaseException as ex:
    logging.error(ex)
    traceback.print_exc()

# Close session
session.close()
{'fraction_non_alphanumeric': 0.13535736875395318, 'fraction_numerical': 0.002530044275774826, 'mean_word_length': 3.4670433145009416, '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': '7168309', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1404, 'n_words': 276}