def messages(location, receiver):
path = filepath.FilePath(location)<EOL>def _check(path):<EOL><INDENT>messageFiles = path.globChildren('<STR_LIT:*>')<EOL>for message in messageFiles:<EOL><INDENT>if message.basename().endswith('<STR_LIT>'):<EOL><INDENT>continue<EOL><DEDENT>receiver.message(message.getContent())<EOL>message.remove()<EOL><DEDENT><DEDENT>return functools.partial(_check, path)<EOL>
Construct a function that checks a directory for messages

    The function checks for new messages and
    calls the appropriate method on the receiver. Sent messages are
    deleted.

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