def checker(location, receiver):
path = filepath.FilePath(location)<EOL>files = set()<EOL>filesContents = {}<EOL>def _check(path):<EOL><INDENT>currentFiles = set(fname for fname in os.listdir(location)<EOL>if not fname.endswith('<STR_LIT>'))<EOL>removed = files - currentFiles<EOL>added = currentFiles - files<EOL>for fname in added:<EOL><INDENT>contents = path.child(fname).getContent()<EOL>filesContents[fname] = contents<EOL>receiver.add(fname, contents)<EOL><DEDENT>for fname in removed:<EOL><INDENT>receiver.remove(fname)<EOL><DEDENT>same = currentFiles & files<EOL>for fname in same:<EOL><INDENT>newContents = path.child(fname).getContent()<EOL>oldContents = filesContents[fname]<EOL>if newContents == oldContents:<EOL><INDENT>continue<EOL><DEDENT>receiver.remove(fname)<EOL>filesContents[fname] = newContents<EOL>receiver.add(fname, newContents)<EOL><DEDENT>files.clear()<EOL>files.update(currentFiles)<EOL><DEDENT>return functools.partial(_check, path)<EOL>
Construct a function that checks a directory for process configuration

    The function checks for additions or removals
    of JSON process configuration files and calls the appropriate receiver
    methods.

    :param location: string, the directory to monitor
    :param receiver: IEventReceiver
    :returns: a function with no parameters