def show(module):
    ret = {}
    ret['name'] = module

    # This section parses out details from CPAN, if possible
    cmd = 'cpan -D {0}'.format(module)
    out = __salt__['cmd.run'](cmd).splitlines()
    mode = 'skip'
    info = []
    for line in out:
        if line.startswith('-------------'):
            mode = 'parse'
            continue
        if mode == 'skip':
            continue
        info.append(line)

    if len(info) == 6:
        # If the module is not installed, we'll be short a line
        info.insert(2, '')
    if len(info) < 6:
        # This must not be a real package
        ret['error'] = 'This package does not seem to exist'
        return ret

    ret['description'] = info[0].strip()
    ret['cpan file'] = info[1].strip()
    if info[2].strip():
        ret['installed file'] = info[2].strip()
    else:
        ret['installed file'] = None
    comps = info[3].split(':')
    if len(comps) > 1:
        ret['installed version'] = comps[1].strip()
    if 'installed version' not in ret or not ret['installed version']:
        ret['installed version'] = None
    comps = info[4].split(':')
    comps = comps[1].split()
    ret['cpan version'] = comps[0].strip()
    ret['author name'] = info[5].strip()
    ret['author email'] = info[6].strip()

    # Check and see if there are cpan build directories
    config = show_config()
    build_dir = config.get('build_dir', None)
    if build_dir is not None:
        ret['cpan build dirs'] = []
        builds = os.listdir(build_dir)
        pfile = module.replace('::', '-')
        for file_ in builds:
            if file_.startswith(pfile):
                ret['cpan build dirs'].append(os.path.join(build_dir, file_))

    return ret
Show information about a specific Perl module
dataset/ETHPy150Open saltstack/salt/salt/modules/cpan.py/show