<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_requirements(output_path=None):
 """ Loop through the INSTALLED_APPS and create a set of requirements for pip. if output_path is ``None`` then write to standard out, otherwise write to the path. """

    from django.conf import settings
    reqs = set()
    
    for app in settings.INSTALLED_APPS:
        if app in mapping.keys():
            reqs |= set(mapping[app])
    if output_path is None:
        print "--extra-index-url=http://opensource.washingtontimes.com/pypi/simple/"
        for item in reqs:
            print item
    else:
        try:
            out_file = open(output_path, 'w')
            out_file.write("--extra-index-url=http://opensource.washingtontimes.com/pypi/simple/\n")
            for item in reqs:
                out_file.write("%s\n" % item)
        finally:
            out_file.close()