Esempio n. 1
0
    def search(self):
        """ Search for plugins. """
        query = self.args.query

        self.p_main('Searching for `{}` through BukGet'.format(query))

        results = [(result, '[{}]{}'.format(result['slug'],
                                            result['plugin_name']))
                   for result in backend.search(query, self.args.size)]

        self.p_main('Results:')
        self.p_blank()

        if len(results) < 1:
            self.p_sub('No results...')
            self.p_blank()
            return

        # Find lenght of longest slug + name
        max_len = max([len(p[1]) for p in results])

        # Create the format
        frmt = '{{:<{}}} - {{}}'.format(max_len)

        for i in range(min(len(results), abs(self.args.size))):
            plugin = results[i]
            line = frmt.format(plugin[1], plugin[0]['description'].strip())
            self.p_sub(line)

        self.p_blank()
Esempio n. 2
0
    def search(self):
        """ Search for plugins. """
        query = self.args.query

        self.p_main('Searching for `{}` through BukGet'.format(query))

        results = [(result, '[{}]{}'.format(result['slug'],
                                            result['plugin_name']))
                   for result in backend.search(query, self.args.size)]

        self.p_main('Results:')
        self.p_blank()

        if len(results) < 1:
            self.p_sub('No results...')
            self.p_blank()
            return

        # Find lenght of longest slug + name
        max_len = max([len(p[1]) for p in results])

        # Create the format
        frmt = '{{:<{}}} - {{}}'.format(max_len)

        for i in range(min(len(results), abs(self.args.size))):
            plugin = results[i]
            line = frmt.format(plugin[1], plugin[0]['description'].strip())
            self.p_sub(line)

        self.p_blank()
Esempio n. 3
0
def test_search(fake_search):
    """ Test plugins.search. """
    plugins.init(None, None)
    result = plugins.search('Foo', 3)
    assert result[0]['slug'] == 'foo'
    assert result[1]['slug'] == 'herp'
    assert result[2]['slug'] == 'first'
    assert result[3]['slug'] == 'lololol'
Esempio n. 4
0
def test_search(fake_search):
    """ Test plugins.search. """
    plugins.init(None, None)
    result = plugins.search("Foo", 3)
    assert result[0]["slug"] == "foo"
    assert result[1]["slug"] == "herp"
    assert result[2]["slug"] == "first"
    assert result[3]["slug"] == "lololol"