<commit_before>#!/usr/bin/env python
import sys
import time
import logging
import os
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from watchdog.events import EVENT_TYPE_MOVED, EVENT_TYPE_DELETED, EVENT_TYPE_CREATED, EVENT_TYPE_MODIFIED

class FSEventHandler(FileSystemEventHandler):
    def on_any_event(self, event):
        """Catch-all event handler.

        :param event:
            The event object representing the file system event.
        :type event:
            :class:`FileSystemEvent`
        """
        if not '.gut' in event.src_path:
            if event.is_directory:
                print '%s %s' % (EVENT_TYPE_CREATED, event.src_path)
            else:
                if event.event_type == EVENT_TYPE_MOVED:
                    print '%s %s' % (EVENT_TYPE_DELETED, event.src_path)
                    print '%s %s' % (EVENT_TYPE_CREATED, event.dest_path)
                else:
                    print '%s %s' % (event.event_type, event.src_path)
            sys.stdout.flush()

if __name__ == "__main__":
    from setproctitle import setproctitle
    setproctitle('gutsmon')
    time.sleep(0.1)<commit_msg>Guard against events that don't have a src_path<commit_after>#!/usr/bin/env python
import sys
import time
import logging
import os
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from watchdog.events import EVENT_TYPE_MOVED, EVENT_TYPE_DELETED, EVENT_TYPE_CREATED, EVENT_TYPE_MODIFIED

class FSEventHandler(FileSystemEventHandler):
    def on_any_event(self, event):
        """Catch-all event handler.

        :param event:
            The event object representing the file system event.
        :type event:
            :class:`FileSystemEvent`
        """
        if event.src_path and not '.gut' in event.src_path:
            if event.is_directory:
                print '%s %s' % (EVENT_TYPE_CREATED, event.src_path)
            else:
                if event.event_type == EVENT_TYPE_MOVED:
                    print '%s %s' % (EVENT_TYPE_DELETED, event.src_path)
                    print '%s %s' % (EVENT_TYPE_CREATED, event.dest_path)
                else:
                    print '%s %s' % (event.event_type, event.src_path)
            sys.stdout.flush()

if __name__ == "__main__":
    from setproctitle import setproctitle
    setproctitle('gutsmon')
    time.sleep(0.1)
{'fraction_non_alphanumeric': 0.08800332088003321, 'fraction_numerical': 0.0016604400166044002, 'mean_word_length': 2.4576757532281204, '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': '4461366', 'n_tokens_mistral': 726, 'n_tokens_neox': 711, 'n_words': 184}