Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Added command 'conda env print' (receives environment.yml file) #125

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions conda_env/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
from . import main_create
from . import main_export
from . import main_list
from . import main_print
from . import main_remove
from . import main_upload
from . import main_update
from . import main_upload


# TODO: This belongs in a helper library somewhere
Expand All @@ -53,9 +54,10 @@ def create_parser():
main_create.configure_parser(sub_parsers)
main_export.configure_parser(sub_parsers)
main_list.configure_parser(sub_parsers)
main_print.configure_parser(sub_parsers)
main_remove.configure_parser(sub_parsers)
main_upload.configure_parser(sub_parsers)
main_update.configure_parser(sub_parsers)
main_upload.configure_parser(sub_parsers)

show_help_on_empty_command()
return p
Expand Down
48 changes: 48 additions & 0 deletions conda_env/cli/main_print.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from __future__ import print_function

description = """
Prints content from environment.yml files.

Handles includes and jinja2 parsing.
"""

example = """
examples:
conda env print path/to/environment.yml
conda env print path/to/environment.yml --json
"""


def configure_parser(sub_parsers):
from argparse import RawDescriptionHelpFormatter

p = sub_parsers.add_parser(
'print',
formatter_class=RawDescriptionHelpFormatter,
description=description,
help=description,
epilog=example,
)
p.add_argument(
'-f', '--file',
action='store',
help='environment definition file (default: environment.yml)',
default='environment.yml',
)

from conda.cli import common
common.add_parser_json(p)

p.set_defaults(func=execute)


def execute(args, parser):
from conda_env.env import from_file
env = from_file(args.file)

if args.json:
from conda.cli.common import stdout_json
stdout_json(env.to_dict())
else:
import sys
env.to_yaml(sys.stdout)