def run(cls, **kwargs): if kwargs['simple']: for pkg in sorted(dapicli.get_installed_daps()): print(pkg) else: for pkg, instances in sorted(dapicli.get_installed_daps_detailed().items()): versions = [] for instance in instances: location = utils.unexpanduser(instance['location']) version = instance['version'] if not versions: # if this is the first version = utils.bold(version) versions.append('{v}:{p}'.format(v=version, p=location)) pkg = utils.bold(pkg) print('{pkg} ({versions})'.format(pkg=pkg, versions=' '.join(versions)))
def _format_dap_with_description(mdap): string = utils.bold(mdap['package_name']) latest = mdap['latest_stable'] or mdap['latest'] if latest: latest = data(latest) string += ' - ' + latest['summary'] return [string]
def test_search(self, capfd): '''Test the print of a search results''' desired = utils.bold('python') + '\n' flexmock(dapicli).should_receive('data').and_return(yaml.load(TestDapicli.search_yaml)) dapicli.print_search('python') out, err = capfd.readouterr() assert out == desired
def print_installed_dap_list(simple=False): '''Prints all installed DAPs in a human readable form to stdout''' if simple: for pkg in sorted(get_installed_daps()): print(pkg) else: for pkg, instances in sorted(get_installed_daps_detailed().items()): versions = [] for instance in instances: location = utils.unexpanduser(instance['location']) version = instance['version'] if not versions: # if this is the first version = utils.bold(version) versions.append('{v}:{p}'.format(v=version, p=location)) pkg = utils.bold(pkg) print('{pkg} ({versions})'.format(pkg=pkg, versions=' '.join(versions)))
def _print_dap_with_description(mdap): print(utils.bold(mdap['package_name']), end='') latest = mdap['latest_stable'] or mdap['latest'] if latest: latest = data(latest) print(' - ', end='') print(latest['summary'], end='') print('')
def test_search(self, capfd): '''Test the print of a search results''' desired = utils.bold('python') + '\n' flexmock(dapicli).should_receive('data').and_return( yaml.load(TestDapicli.search_yaml)) for line in dapicli.format_search('python'): print(line) out, err = capfd.readouterr() assert out == desired
def format_installed_dap_list(simple=False): '''Formats all installed DAPs in a human readable form to list of lines''' lines = [] if simple: for pkg in sorted(get_installed_daps()): lines.append(pkg) else: for pkg, instances in sorted(get_installed_daps_detailed().items()): versions = [] for instance in instances: location = utils.unexpanduser(instance['location']) version = instance['version'] if not versions: # if this is the first version = utils.bold(version) versions.append('{v}:{p}'.format(v=version, p=location)) pkg = utils.bold(pkg) lines.append('{pkg} ({versions})'.format( pkg=pkg, versions=' '.join(versions))) return lines
def test_search_good_options(self): res = run_da('pkg search common_args --noassistants') assert utils.bold('common_args') in res.stdout
def test_search(self): res = run_da('pkg search devassistant') assert utils.bold('devassistant') in res.stdout