<commit_before>import os
import sqlite3
import mutagen
import logging
from watchdog.events import FileSystemEventHandler

import gevent
from gevent.pool import Pool

def update_job(url):
    """ Scan a file.

    """
    
    
class CollectionEventHandler(FileSystemEventHandler):
    def __init__(self, scanner):
        self.scanner = scanner

    def on_created(self, event):
        pass

    def on_modified(self, event):
        pass

class CollectionScanner(object):
    def __init__(self, list_of_directories):
        self.log = logging.getLogger('collectionscanner')
        self.log.addHandler(logging.StreamHandler())
        self.log.setLevel(logging.DEBUG)
        self.directories = list_of_directories

    def update(self, url):
        self.log.debug("Updating %s", url)
        gevent.sleep(0.5)

    def requires_update(self):
        return False

    def full_scan(self):
        # incremental scan with require_update always true
        old_requires_update = self.requires_update
        self.requires_update = lambda x: True
        self.incremental_scan()
        self.requires_update = old_requires_update

    def incremental_scan(self):
        job_pool = Pool(10)

        for directory in self.directories:
            for dirpath, dirnames, filenames in os.walk(directory):
                # only get the directories we know are modified
                # this way os.walk is more efficient
                [dirnames.remove(dir) for dir in dirnames if not self.requires_update(os.path.join(dirpath, dir))]
                
                self.log.debug("Directory %s Scanning %s", dirpath, dirnames)

                for file in filenames:
                    fn = os.path.join(dirpath, file)
                    if self.requires_update(fn):
                        # TODO: Do we wait around for updates to occur
                        # or do we have a two step pool
                    	job_pool.spawn(self.update, fn)<commit_msg>Print meta-data of all files<commit_after>import os
import sqlite3
import logging
from watchdog.events import FileSystemEventHandler

import gevent
from gevent.pool import Pool

from muzicast.formats import MusicFile

def update_job(url):
    """ Scan a file.

    """
    f = MusicFile(url)
    
class CollectionEventHandler(FileSystemEventHandler):
    def __init__(self, scanner):
        self.scanner = scanner

    def on_created(self, event):
        pass

    def on_modified(self, event):
        pass

class CollectionScanner(object):
    def __init__(self, list_of_directories):
        self.log = logging.getLogger('collectionscanner')
        self.log.addHandler(logging.StreamHandler())
        self.log.setLevel(logging.DEBUG)
        self.directories = list_of_directories

    def update(self, url):
        self.log.debug("Updating %s", url)
        gevent.sleep(0.5)

    def requires_update(self):
        return False

    def full_scan(self):
        # incremental scan with require_update always true
        old_requires_update = self.requires_update
        self.requires_update = lambda x: True
        self.incremental_scan()
        self.requires_update = old_requires_update

    def incremental_scan(self):
        job_pool = Pool(10)

        for directory in self.directories:
            for dirpath, dirnames, filenames in os.walk(directory):
                # only get the directories we know are modified
                # this way os.walk is more efficient
                [dirnames.remove(dir) for dir in dirnames if not self.requires_update(os.path.join(dirpath, dir))]
                
                self.log.debug("Directory %s Scanning %s", dirpath, dirnames)

                for file in filenames:
                    fn = os.path.join(dirpath, file)
                    if self.requires_update(fn):
                        # TODO: Do we wait around for updates to occur
                        # or do we have a two step pool
                        job_pool.spawn(update_job, fn)
        job_pool.join()
{'fraction_non_alphanumeric': 0.0774402390438247, 'fraction_numerical': 0.00249003984063745, 'mean_word_length': 2.2136, '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': '4974079', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1075, 'n_words': 304}