def installed(name, env=None, saltenv='<STR_LIT>', user=None):
ret = {'<STR_LIT:name>': name, '<STR_LIT>': {}, '<STR_LIT>': '<STR_LIT>', '<STR_LIT:result>': True}<EOL>packages = []<EOL>if os.path.exists(name) or name.startswith('<STR_LIT>'):<EOL><INDENT>if name.startswith('<STR_LIT>'):<EOL><INDENT>lines = __salt__['<STR_LIT>'](name, saltenv)<EOL>lines = lines.split('<STR_LIT:\n>')<EOL><DEDENT>elif os.path.exists(name):<EOL><INDENT>f = open(name, mode='<STR_LIT:r>')<EOL>lines = f.readlines()<EOL>f.close()<EOL><DEDENT>for line in lines:<EOL><INDENT>line = line.strip()<EOL>if line != '<STR_LIT>' and not line.startswith('<STR_LIT:#>'):<EOL><INDENT>line = line.split('<STR_LIT:#>')[<NUM_LIT:0>].strip()    <EOL>packages.append(line)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>packages = [pkg.strip() for pkg in name.split('<STR_LIT:U+002C>')]<EOL><DEDENT>conda_list = __salt__['<STR_LIT>'](env=env, user=user)<EOL>def extract_info(pkgname):<EOL><INDENT>pkgname, pkgversion = package, '<STR_LIT>'<EOL>pkgname, pkgversion = (package.split('<STR_LIT>')[<NUM_LIT:0>], package.split('<STR_LIT>')[<NUM_LIT:1>]<EOL>) if '<STR_LIT>' in package else (package, pkgversion)<EOL>pkgname, pkgversion = (package.split('<STR_LIT>')[<NUM_LIT:0>], package.split('<STR_LIT>')[<NUM_LIT:1>]<EOL>) if '<STR_LIT>' in package else (pkgname, pkgversion)<EOL>pkgname, pkgversion = (package.split('<STR_LIT:>>')[<NUM_LIT:0>], package.split('<STR_LIT>')[<NUM_LIT:1>]<EOL>) if '<STR_LIT:>>' in package else (pkgname, pkgversion)<EOL>return pkgname, pkgversion<EOL><DEDENT>installed, failed, old = <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0><EOL>for package in packages:<EOL><INDENT>pkgname, pkgversion = extract_info(package)<EOL>conda_pkgname = pkgname + '<STR_LIT:U+0020>' * (<NUM_LIT> - len(pkgname)) + pkgversion<EOL>if conda_pkgname not in conda_list:<EOL><INDENT>installation = __salt__['<STR_LIT>'](package, env=env, user=user)<EOL>if installation['<STR_LIT>'] == <NUM_LIT:0>:<EOL><INDENT>ret['<STR_LIT>'][package] = '<STR_LIT>'<EOL>installed += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ret['<STR_LIT>'][package] = installation<EOL>failed += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>old += <NUM_LIT:1><EOL><DEDENT><DEDENT>comments = []<EOL>if installed > <NUM_LIT:0>:<EOL><INDENT>comments.append('<STR_LIT>'.format(installed))<EOL><DEDENT>if failed > <NUM_LIT:0>:<EOL><INDENT>ret['<STR_LIT:result>'] = False<EOL>comments.append('<STR_LIT>'.format(failed))<EOL><DEDENT>if old > <NUM_LIT:0>:<EOL><INDENT>comments.append('<STR_LIT>'.format(old))<EOL><DEDENT>ret['<STR_LIT>'] = '<STR_LIT:U+002CU+0020>'.join(comments)<EOL>return ret<EOL>
Installs a single package, list of packages (comma separated) or packages in a requirements.txt

Checks if the package is already in the environment.
Check ocurres here so is only needed to `conda list` and `pip freeze` once

name
    name of the package(s) or path to the requirements.txt
env : None
    environment name or path where to put the new enviroment
    if None (default) will use the default conda environment (`~/anaconda/bin`)
saltenv : 'base'
    Salt environment. Usefull when the name is file using the salt file system
    (e.g. `salt://.../reqs.txt`)
user
    The user under which to run the commands