<commit_before>;;;;; tré – Copyright (c) 2008–2013 <NAME> <<EMAIL>>

(defclass event-module (name)
  (log-events "New event module `~A'.~%" name)
  (= _name     name
	 _handlers nil
	 _killed?  nil)
  this)

(defmember event-module
	_name
	_handlers
	_killed?)

(defmethod event-module get-name ()      _name)
(defmethod event-module set-name (name)  (= _name name))
(defmethod event-module handlers ()      _handlers)

(defmethod event-module _hook-type (type callback-fun elm)
  (with (slf      this
         handler  (new _event-handler (? (undefined? elm) nil elm) type callback-fun))
    (push handler _handlers)
    (when elm
      (push #'(()
                 (= _handlers (remove-if [_.has-element elm] _handlers)))
            elm._unhooks))))

(defmethod event-module hook (types callback-fun elm)
  (assert (function? callback-fun) "callback is not a function")
  (when elm
	(= elm._hooked? t))
  (adolist ((ensure-list types) elm)
    (log-events "Module ~A will catch ~A events.~%" _name !)
    (_hook-type ! callback-fun elm)))

(defmethod event-module _unhook-0 (obj)
 (= _handlers (remove-if [?
                           (function? obj)  (_.has-callback obj)
			               (element? obj)   (_.has-element obj)
			               (string? obj)    (_.has-type obj)]
                         _handlers)))

(defmethod event-module unhook (obj)
  (?
    (cons? obj)           (adolist obj
	                        (unhook !))
    (& (element? obj)
       obj._hooked?)      (_unhook-0 obj)
	(not (comment? obj))  (_unhook-0 obj)))

(defmethod event-module close ())

(defmethod event-module kill ()
  (event-manager.kill this))

(finalize-class event-module)<commit_msg>New default event module is in *EVENT-MODULE*.<commit_after>;;;;; tré – Copyright (c) 2008–2013 <NAME> <<EMAIL>>

(defclass event-module (name)
  (log-events "New event module `~A'.~%" name)
  (= _name     name
	 _handlers nil
	 _killed?  nil)
  this)

(defmember event-module
	_name
	_handlers
	_killed?)

(defmethod event-module get-name ()      _name)
(defmethod event-module set-name (name)  (= _name name))
(defmethod event-module handlers ()      _handlers)

(defmethod event-module _hook-type (type callback-fun elm)
  (with (slf      this
         handler  (new _event-handler (? (undefined? elm) nil elm) type callback-fun))
    (push handler _handlers)
    (when elm
      (push #'(()
                 (= _handlers (remove-if [_.has-element elm] _handlers)))
            elm._unhooks))))

(defmethod event-module hook (types callback-fun elm)
  (assert (function? callback-fun) "callback is not a function")
  (when elm
	(= elm._hooked? t))
  (adolist ((ensure-list types) elm)
    (log-events "Module ~A will catch ~A events.~%" _name !)
    (_hook-type ! callback-fun elm)))

(defmethod event-module _unhook-0 (obj)
 (= _handlers (remove-if [?
                           (function? obj)  (_.has-callback obj)
			               (element? obj)   (_.has-element obj)
			               (string? obj)    (_.has-type obj)]
                         _handlers)))

(defmethod event-module unhook (obj)
  (?
    (cons? obj)           (adolist obj
	                        (unhook !))
    (& (element? obj)
       obj._hooked?)      (_unhook-0 obj)
	(not (comment? obj))  (_unhook-0 obj)))

(defmethod event-module close ())

(defmethod event-module kill ()
  (event-manager.kill this))

(finalize-class event-module)

(defvar *event-module* (make-event-module "default"))
{'fraction_non_alphanumeric': 0.14256795835743205, 'fraction_numerical': 0.006362058993637941, 'mean_word_length': 2.4974721941354905, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2546527', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1154, 'n_words': 317}