unity-scope-launchpad-0.1daily13.06.05/0000755000015700001700000000000012153555205020422 5ustar pbuserpbgroup00000000000000unity-scope-launchpad-0.1daily13.06.05/po/0000755000015700001700000000000012153555205021040 5ustar pbuserpbgroup00000000000000unity-scope-launchpad-0.1daily13.06.05/po/unity-scope-launchpad.pot0000644000015700001700000000235312153554554026011 0ustar pbuserpbgroup00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2013-02-21 01:56+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/unity_launchpad_daemon.py:31 ../data/launchpad.scope.in.h:4 msgid "Search Launchpad" msgstr "" #: ../src/unity_launchpad_daemon.py:32 msgid "Sorry, there are no Launchpad bugs or projects that match your search." msgstr "" #: ../src/unity_launchpad_daemon.py:33 msgid "Powered by Launchpad" msgstr "" #: ../src/unity_launchpad_daemon.py:41 msgid "Projects" msgstr "" #: ../src/unity_launchpad_daemon.py:45 msgid "Bugs" msgstr "" #: ../data/launchpad.scope.in.h:1 msgid "launchpad;code;bug;project;lp;" msgstr "" #: ../data/launchpad.scope.in.h:2 msgid "Launchpad" msgstr "" #: ../data/launchpad.scope.in.h:3 msgid "Find Launchpad bugs and projects" msgstr "" unity-scope-launchpad-0.1daily13.06.05/po/POTFILES.in0000644000015700001700000000013312153554554022620 0ustar pbuserpbgroup00000000000000[encoding: UTF-8] src/unity_launchpad_daemon.py [type: gettext/ini]data/launchpad.scope.in unity-scope-launchpad-0.1daily13.06.05/MANIFEST.in0000644000015700001700000000007612153554554022171 0ustar pbuserpbgroup00000000000000include MANIFEST.in include src/* include data/* include po/* unity-scope-launchpad-0.1daily13.06.05/tests/0000755000015700001700000000000012153555205021564 5ustar pbuserpbgroup00000000000000unity-scope-launchpad-0.1daily13.06.05/tests/test_launchpad.py0000644000015700001700000000434312153554554025146 0ustar pbuserpbgroup00000000000000#! /usr/bin/python3 # -*- coding: utf-8 -*- from gi.repository import Unity from unittest import TestCase import imp class ResultSet(Unity.ResultSet): def __init__(self): Unity.ResultSet.__init__(self) self.results = [] def do_add_result(self, result): self.results.append({'uri':result.uri, 'title':result.title, 'comment':result.comment, 'icon':result.icon_hint}) class ScopeTestCase(TestCase): def init_scope(self, scope_path): self.scope_module = imp.load_source('scope', scope_path) self.scope = self.scope_module.load_scope() def perform_query(self, query, filter_set = Unity.FilterSet.new()): result_set = ResultSet() ctx = Unity.SearchContext.create(query, 0, filter_set, None, result_set, None) s = self.scope.create_search_for_query(ctx) s.run() return result_set class TestLaunchpad(ScopeTestCase): def setUp(self): self.init_scope('src/unity_launchpad_daemon.py') def tearDown(self): self.scope = None self.scope_module = None # def test_valid_searches(self): # self.scope_module.SEARCH_URI = 'file:tests/data/mock_launchpad_pass#' # expected_results = ['https://launchpad.net/hud', # 'https://api.launchpad.net/1.0/hud/logo', # 'Unity HUD', # 'https://bugs.launchpad.net/bugs/1', # '/usr/share/icons/unity-icon-theme/places/svg/result-developer.svg', # 'Microsoft has a majority market share'] # results = [] # for s in ['unity hud', '#1']: # result_set = self.perform_query(s) # results.append(result_set.results[0]['uri']) # results.append(result_set.results[0]['icon']) # results.append(result_set.results[0]['title']) # self.assertEqual(results, expected_results) def test_failing_search(self): for s in ['']: result_set = self.perform_query(s) self.assertEqual(len(result_set.results), 0) if __name__ == '__main__': unittest.main() unity-scope-launchpad-0.1daily13.06.05/src/0000755000015700001700000000000012153555205021211 5ustar pbuserpbgroup00000000000000unity-scope-launchpad-0.1daily13.06.05/src/unity_launchpad_daemon.py0000644000015700001700000002057312153554554026312 0ustar pbuserpbgroup00000000000000#! /usr/bin/python # -*- coding: utf-8 -*- # Copyright (C) 2013 David Callé # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . from gi.repository import Unity, UnityExtras from gi.repository import Gio, GLib from launchpadlib.launchpad import Launchpad import gettext import datetime APP_NAME = 'unity-scope-launchpad' LOCAL_PATH = '/usr/share/locale/' gettext.bindtextdomain(APP_NAME, LOCAL_PATH) gettext.textdomain(APP_NAME) _ = gettext.gettext GROUP_NAME = 'com.canonical.Unity.Scope.Developer.Launchpad' UNIQUE_PATH = '/com/canonical/unity/scope/developer/launchpad' SEARCH_URI = '' SEARCH_HINT = _('Search Launchpad') NO_RESULTS_HINT = _('Sorry, there are no Launchpad bugs or projects that match your search.') PROVIDER_CREDITS = _('Powered by Launchpad') SVG_DIR = '/usr/share/icons/unity-icon-theme/places/svg/' PROVIDER_ICON = SVG_DIR+'service-launchpad.svg' DEFAULT_RESULT_ICON = SVG_DIR+'group-developer.svg' DEFAULT_RESULT_MIMETYPE = 'text/html' DEFAULT_RESULT_TYPE = Unity.ResultType.DEFAULT c1 = {'id' :'code', 'name' :_('Projects'), 'icon' :SVG_DIR+'group-developer.svg', 'renderer':Unity.CategoryRenderer.VERTICAL_TILE} c2 = {'id' :'people', 'name' :_('Bugs'), 'icon' :SVG_DIR+'group-developer.svg', 'renderer':Unity.CategoryRenderer.VERTICAL_TILE} CATEGORIES = [c1, c2] FILTERS = [] EXTRA_METADATA = [] lp = Launchpad.login_anonymously('unity-lens-launchpad', 'production') def search(search, filters): ''' Any search method returning results as a list of tuples. Available tuple fields: uri (string) icon (string) title (string) comment (string) dnd_uri (string) mimetype (string) category (int) result_type (Unity ResultType) extras metadata fields (variant) ''' results = [] if len(search) < 2: return results if search[0] == '#': search = search[1:] if search.isdigit(): try: bug = lp.bugs[search] if bug.title and bug.description: results.append({'uri':str(bug.web_link), 'category':1, 'title':bug.title.encode('utf-8'), 'comment':bug.description.encode('utf-8')}) except Exception as error: print (error) if not len(search) >= 3 and search.isdigit(): return results for project in lp.projects.search(text=search): results.append({'uri':str(project.web_link), 'icon':str(project.brand_link), 'title':str(project.title.encode('utf-8')), 'comment':str(project.name.encode('utf-8'))}) if len(results) > 25: break return results # Classes below this point establish communication # with Unity, you probably shouldn't modify them. class MySearch (Unity.ScopeSearchBase): def __init__(self, search_context): super (MySearch, self).__init__() self.set_search_context (search_context) def do_run (self): ''' Adds results to the model ''' try: result_set = self.search_context.result_set for i in search(self.search_context.search_query, self.search_context.filter_state): if not 'uri' in i or not i['uri'] or i['uri'] == '': continue if not 'icon' in i or not i['icon'] or i['icon'] == '': i['icon'] = DEFAULT_RESULT_ICON if not 'mimetype' in i or not i['mimetype'] or i['mimetype'] == '': i['mimetype'] = DEFAULT_RESULT_MIMETYPE if not 'result_type' in i or not i['result_type'] or i['result_type'] == '': i['result_type'] = DEFAULT_RESULT_TYPE if not 'category' in i or not i['category'] or i['category'] == '': i['category'] = 0 if not 'title' in i or not i['title']: i['title'] = '' if not 'comment' in i or not i['comment']: i['comment'] = '' if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '': i['dnd_uri'] = i['uri'] result_set.add_result(**i) except Exception as error: print (error) class Preview (Unity.ResultPreviewer): def do_run(self): project = lp.projects(self.result.comment) image = Gio.FileIcon.new(Gio.file_new_for_uri(self.result.icon_hint)) screenshot = project.screenshots_url if screenshot and screenshot != '': if screenshot.endswith('.jpg') or screenshot.endswith('.png'): image = Gio.FileIcon.new(Gio.file_new_for_uri(screenshot)) description = project.description if description: description = description.encode('utf-8') else: description = '' preview = Unity.GenericPreview.new(self.result.title, description, image) summary = project.summary if summary: summary = summary.encode('utf-8') preview.props.subtitle = summary created = project.date_created if created: created = created.strftime('%x') preview.add_info(Unity.InfoHint.new("created", _("Created"), None, str(created))) licenses = project.licenses if licenses: licenses = ','.join(licenses) if ',' in licenses: license_display = _("Licenses") else: license_display = _("License") preview.add_info(Unity.InfoHint.new("licenses", license_display, None, licenses)) programming_language = project.programming_language if programming_language: programming_language = programming_language.encode('utf-8') if ',' in programming_language: language_display = _("Languages") else: language_display = _("Language") preview.add_info(Unity.InfoHint.new("languages", language_display, None, programming_language)) icon = Gio.FileIcon.new (Gio.file_new_for_path(PROVIDER_ICON)) view_action = Unity.PreviewAction.new("view", _("View"), icon) preview.add_action(view_action) return preview class Scope (Unity.AbstractScope): def __init__(self): Unity.AbstractScope.__init__(self) def do_get_search_hint (self): return SEARCH_HINT def do_get_schema (self): ''' Adds specific metadata fields ''' schema = Unity.Schema.new () if EXTRA_METADATA: for m in EXTRA_METADATA: schema.add_field(m['id'], m['type'], m['field']) #FIXME should be REQUIRED for credits schema.add_field('provider_credits', 's', Unity.SchemaFieldType.OPTIONAL) return schema def do_get_categories (self): ''' Adds categories ''' cs = Unity.CategorySet.new () if CATEGORIES: for c in CATEGORIES: cat = Unity.Category.new (c['id'], c['name'], Gio.ThemedIcon.new(c['icon']), c['renderer']) cs.add (cat) return cs def do_get_filters (self): ''' Adds filters ''' fs = Unity.FilterSet.new () # if FILTERS: # return fs def do_get_group_name (self): return GROUP_NAME def do_get_unique_name (self): return UNIQUE_PATH def do_create_search_for_query (self, search_context): se = MySearch (search_context) return se def do_create_previewer(self, result, metadata): rp = Preview() rp.set_scope_result(result) rp.set_search_metadata(metadata) return rp def load_scope(): return Scope() unity-scope-launchpad-0.1daily13.06.05/src/__init__.py0000644000015700001700000000000012153554554023316 0ustar pbuserpbgroup00000000000000unity-scope-launchpad-0.1daily13.06.05/setup.py0000644000015700001700000000123612153554554022144 0ustar pbuserpbgroup00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- from distutils.core import setup from DistUtilsExtra.command import * setup(name='unity-scope-launchpad', version='0.1', author='David Callé', author_email='davidc@framli.eu', url='http://launchpad.net/ubuntu-scopes', license='GNU General Public License (GPL)', data_files=[ ('share/dbus-1/services', ['data/unity-scope-launchpad.service']), ('share/unity-scopes/launchpad', ['src/unity_launchpad_daemon.py']), ('share/unity-scopes/launchpad', ['src/__init__.py']), ], cmdclass={'build': build_extra.build_extra, 'build_i18n': build_i18n.build_i18n,}) unity-scope-launchpad-0.1daily13.06.05/setup.cfg0000644000015700001700000000020712153554554022250 0ustar pbuserpbgroup00000000000000[build] i18n=True [build_i18n] domain=unity-scope-launchpad desktop_files=[('share/unity/scopes/code', ('data/launchpad.scope.in',))] unity-scope-launchpad-0.1daily13.06.05/data/0000755000015700001700000000000012153555205021333 5ustar pbuserpbgroup00000000000000unity-scope-launchpad-0.1daily13.06.05/data/unity-scope-launchpad.service0000644000015700001700000000030112153554554027131 0ustar pbuserpbgroup00000000000000[D-BUS Service] Name=com.canonical.Unity.Scope.Developer.Launchpad Exec=/usr/bin/python /usr/share/unity-scopes/scope-runner-dbus.py /usr/share/unity-scopes/launchpad/unity_launchpad_daemon.py unity-scope-launchpad-0.1daily13.06.05/data/launchpad.scope.in0000644000015700001700000000131012153554554024733 0ustar pbuserpbgroup00000000000000[Scope] DBusName=com.canonical.Unity.Scope.Developer.Launchpad DBusPath=/com/canonical/unity/scope/developer/launchpad Icon=/usr/share/icons/unity-icon-theme/places/svg/service-launchpad.svg _Keywords=launchpad;code;bug;project;lp; RequiredMetadata= OptionalMetadata= Loader=/usr/share/unity-scopes/launchpad/unity_launchpad_daemon.py RemoteContent=true Type=code _Name=Launchpad _Description=This is an Ubuntu search plugin that enables information from Launchpad to be searched and displayed in the Dash underneath the Code header. If you do not wish to search this content source, you can disable this search plugin. _SearchHint=Search Launchpad [Desktop Entry] X-Ubuntu-Gettext-Domain=unity-scope-launchpad unity-scope-launchpad-0.1daily13.06.05/data/icons/0000755000015700001700000000000012153555205022446 5ustar pbuserpbgroup00000000000000unity-scope-launchpad-0.1daily13.06.05/data/icons/service-launchpad.svg0000644000015700001700000000722512153554554026600 0ustar pbuserpbgroup00000000000000 image/svg+xml