def has_main_loop(f):
    """
    Simple test to see if a py-file has a method called 'main_loop'
    """
    if not f.lower().endswith(".py"):
        return False

    try:
        descriptor = open(f)
    except:
        return False
    try:
        while True:
            try:
                line = descriptor.readline()
            except:
                line = None
            if not line:
                break
            if line.startswith("def main_loop():"):
                descriptor.close()
                return True
        descriptor.close()
        return False
    except:
        descriptor.close()
        return False