<commit_before>#!/usr/bin/env python
# -*- coding:utf-8 -*-

"""
Main function
Load from the blobs configuration file
Create the cherrypy server
"""

import cherrypy
import os
import os.path
import sys
from module import Blob
from error import print_usage_function

def CORS(): 
  cherrypy.response.headers["Access-Control-Allow-Origin"] = "*" # mean: CORS to 

if __name__ == '__main__':

    cherrypy.tools.CORS = cherrypy.Tool('before_handler', CORS) 

    if len(sys.argv) == 2 and os.path.isfile(sys.argv[1]):
        VALUE = sys.argv[1]
    else:
        print_usage_function(sys.argv[0])
        sys.exit(1)

    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    CONF_FILE = os.path.join(BASE_DIR, VALUE)

    cherrypy.config.update(CONF_FILE)

    FINAL = cherrypy.config['final.dir']
    THUMB = cherrypy.config['thumbnail.dir']

    CONF = {
        '/' : {
            'tools.staticdir.root': os.getcwd(),
        },
        '/blob_directory': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': FINAL
        },
        '/thumbnail': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': THUMB
        }

    }

    cherrypy.config.update(CONF)

    APP = cherrypy.tree.mount(Blob(), '/', CONF)
    APP.merge(CONF_FILE)

    if hasattr(cherrypy.engine, "signal_handler"):
        cherrypy.engine.signal_handler.subscribe()
    if hasattr(cherrypy.engine, "console_control_handler"):
        cherrypy.engine.console_control_handler.subscribe()
    cherrypy.engine.start()
    cherrypy.engine.block()
<commit_msg>[modules/blobs] renamed module.py as blob.py<commit_after>#!/usr/bin/env python
# -*- coding:utf-8 -*-

"""
Main function
Load from the blobs configuration file
Create the cherrypy server
"""

import cherrypy
import os
import os.path
import sys
from blob import Blob
from error import print_usage_function

def CORS(): 
  cherrypy.response.headers["Access-Control-Allow-Origin"] = "*" # mean: CORS to 

if __name__ == '__main__':

    cherrypy.tools.CORS = cherrypy.Tool('before_handler', CORS) 

    if len(sys.argv) == 2 and os.path.isfile(sys.argv[1]):
        VALUE = sys.argv[1]
    else:
        print_usage_function(sys.argv[0])
        sys.exit(1)

    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    CONF_FILE = os.path.join(BASE_DIR, VALUE)

    cherrypy.config.update(CONF_FILE)

    FINAL = cherrypy.config['final.dir']
    THUMB = cherrypy.config['thumbnail.dir']

    CONF = {
        '/' : {
            'tools.staticdir.root': os.getcwd(),
        },
        '/blob_directory': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': FINAL
        },
        '/thumbnail': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': THUMB
        }

    }

    cherrypy.config.update(CONF)

    APP = cherrypy.tree.mount(Blob(), '/', CONF)
    APP.merge(CONF_FILE)

    if hasattr(cherrypy.engine, "signal_handler"):
        cherrypy.engine.signal_handler.subscribe()
    if hasattr(cherrypy.engine, "console_control_handler"):
        cherrypy.engine.console_control_handler.subscribe()
    cherrypy.engine.start()
    cherrypy.engine.block()

{'fraction_non_alphanumeric': 0.1396297458424851, 'fraction_numerical': 0.0037652965171007216, 'mean_word_length': 2.7330210772833725, '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': '5372399', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1062, 'n_words': 186}