<commit_before>local M = {}

local sched=require 'sched'
local toribio = require 'toribio'
local log = require 'log'

M.init = function( conf )
	local masks_to_watch = {}
	local deviceloadersconf = toribio.configuration.deviceloaders

	for modulename, devmask in pairs(conf.module) do
		log('FILEDEV','INFO', 'watching path %s for module %s', tostring(devmask), tostring(modulename))
		masks_to_watch[devmask] = modulename
		masks_to_watch[#masks_to_watch+1] = devmask
	end

	sched.run(function()
		local inotifier_task = require 'catalog'.get_catalog('tasks'):waitfor(masks_to_watch)
		local waitd_fileevent = {emitter=inotifier_task, events={'FILE+', 'FILE-'}, buff_len=100}
		while true do
			local _, action, devfile, onmask = sched.wait(waitd_fileevent)
			if action=='FILE+' then
				local modulename = masks_to_watch[onmask]
				log('FILEDEV','INFO', 'starting module %s on %s', tostring(modulename), tostring(devfile))
				print('filedev module starting', devfile, modulename)
				deviceloadersconf[modulename] = deviceloadersconf[modulename] or {}
				deviceloadersconf[modulename].filename = devfile
				toribio.start('deviceloaders', modulename)
			elseif action=='FILE-' then
				toribio.remove_devices({filename=devfile})
			end
		end
	end)
	
	local inotifier = require 'tasks/inotifier'
	inotifier.init(masks_to_watch)
end

return M<commit_msg>do not choque on no modules configured<commit_after>local M = {}

local sched=require 'sched'
local toribio = require 'toribio'
local log = require 'log'

M.init = function( conf )
	local masks_to_watch = {}
	local deviceloadersconf = toribio.configuration.deviceloaders

	for modulename, devmask in pairs(conf.module or {}) do
		log('FILEDEV','INFO', 'watching path %s for module %s', tostring(devmask), tostring(modulename))
		masks_to_watch[devmask] = modulename
		masks_to_watch[#masks_to_watch+1] = devmask
	end

	sched.run(function()
		local inotifier_task = require 'catalog'.get_catalog('tasks'):waitfor(masks_to_watch)
		local waitd_fileevent = {emitter=inotifier_task, events={'FILE+', 'FILE-'}, buff_len=100}
		while true do
			local _, action, devfile, onmask = sched.wait(waitd_fileevent)
			if action=='FILE+' then
				local modulename = masks_to_watch[onmask]
				log('FILEDEV','INFO', 'starting module %s on %s', tostring(modulename), tostring(devfile))
				print('filedev module starting', devfile, modulename)
				deviceloadersconf[modulename] = deviceloadersconf[modulename] or {}
				deviceloadersconf[modulename].filename = devfile
				toribio.start('deviceloaders', modulename)
			elseif action=='FILE-' then
				toribio.remove_devices({filename=devfile})
			end
		end
	end)
	
	local inotifier = require 'tasks/inotifier'
	inotifier.init(masks_to_watch)
end

return M
{'fraction_non_alphanumeric': 0.11867491809246451, 'fraction_numerical': 0.0029122679286494356, 'mean_word_length': 5.621686746987952, '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': '7117195', 'n_tokens_mistral': 1049, 'n_tokens_neox': 953, 'n_words': 208}