# Buggy code
def execute(args, parser):
    prefix = context.prefix_w_legacy_search

    regex = args.regex
    if args.full_name:
        regex = r"^%s$" % regex

    if args.revisions:
        from conda.history import History

        h = History(prefix)
        if isfile(h.path):
            if not args.json:
                h.print_log()
            else:
                stdout_json(h.object_log())
        else:
            raise CondaFileNotFoundError(h.path, "No revision log found: %s\n" % h.path)
        return

    if args.explicit:
        print_explicit(prefix, args.md5)
        return

    if args.canonical:
        format = "canonical"
    elif args.export:
        format = "export"
    else:
        format = "human"

    if args.json:
        format = "canonical"

    exitcode = print_packages(
        prefix,
        regex,
        format,
        piplist=args.pip,
        json=args.json,
        show_channel_urls=args.show_channel_urls,
    )
    return exitcode


# Traceback (AttributeError)
n unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues


Current conda install:

platform : linux-64
conda version : 4.2.1
conda is private : False
conda-env version : 2.5.2
conda-build version : 1.21.11+0.g5b44ab3.dirty
python version : 2.7.12.final.0
requests version : 2.10.0
root environment : /reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7  (writable)
default environment : /reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/envs/anabase
envs directories : /reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/envs
package cache : /reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/pkgs
channel URLs : file:///reg/g/psdm/sw/conda/channels/system-rhel7
file:///reg/g/psdm/sw/conda/channels/psana-rhel7
file:///reg/g/psdm/sw/conda/channels/external-rhel7
defaults
scikit-beam
file:///reg/g/psdm/sw/conda/channels/testing-rhel7
config file : /reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/.condarc
offline mode : False


`$ /reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/bin/conda-env export`


Traceback (most recent call last):
File "/reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/lib/python2.7/site-packages/conda/exceptions.py", line 403, in conda_exception_handler
return_value = func(*args, **kwargs)
File "/reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/lib/python2.7/site-packages/conda_env/cli/main_export.py", line 93, in execute
ignore_channels=args.ignore_prefix)
AttributeError: 'Namespace' object has no attribute 'ignore_prefix'
../manage/config/environment-anabase-1.0.0.yml (END)

# Fixed code
def execute(args, parser):
    prefix = context.prefix_w_legacy_search

    regex = args.regex
    if args.full_name:
        regex = r"^%s$" % regex

    if args.revisions:
        from conda.history import History

        h = History(prefix)
        if isfile(h.path):
            if not args.json:
                h.print_log()
            else:
                stdout_json(h.object_log())
        else:
            raise CondaFileNotFoundError(h.path, "No revision log found: %s\n" % h.path)
        return

    if args.explicit:
        print_explicit(prefix, args.md5)
        return

    if args.canonical:
        format = "canonical"
    elif args.export:
        print_explicit(prefix, args.md5)
        return
    else:
        format = "human"

    if args.json:
        format = "canonical"

    exitcode = print_packages(
        prefix,
        regex,
        format,
        piplist=args.pip,
        json=args.json,
        show_channel_urls=args.show_channel_urls,
    )
    return exitcode