Eu li um tutorial sobre como compilar e instalar uma lente da Wikipedia, mas não funcionou.
O tutorial parece fácil - eu apenas copiei e colei no arquivo que deveria ser editado.
Eu tentei algumas vezes e aqui estão 2 edições
edite 1:
import logging
import optparse
import gettext
from gettext import gettext as _
gettext.textdomain('wikipedia')
from singlet.lens import SingleScopeLens, IconViewCategory, ListViewCategory
from wikipedia import wikipediaconfig
import urllib2
import simplejson
class WikipediaLens(SingleScopeLens):
wiki = "http://en.wikipedia.org"
def wikipedia_query(self,search):
try:
search = search.replace(" ", "|")
url = ("%s/w/api.php?action=opensearch&limit=25&format=json&search=%s" % (self.wiki, search))
results = simplejson.loads(urllib2.urlopen(url).read())
print "Searching Wikipedia"
return results[1]
except (IOError, KeyError, urllib2.URLError, urllib2.HTTPError, simplejson.JSONDecodeError):
print "Error : Unable to search Wikipedia"
return []
class Meta:
name = 'Wikipedia'
description = 'Wikipedia Lens'
search_hint = 'Search Wikipedia'
icon = 'wikipedia.svg'
search_on_blank=True
# TODO: Add your categories
articles_category = ListViewCategory("Articles", "dialog-information-symbolic")
def search(self, search, results):
for article in self.wikipedia_query(search):
results.append("%s/wiki/%s" % (self.wiki, article),
"http://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png",
self.articles_category,
"text/html",
article,
"Wikipedia Article",
"%s/wiki/%s" % (self.wiki, article))
pass
edição 2:
import urllib2
import simplejson
import logging
import optparse
import gettext
from gettext import gettext as _
gettext.textdomain('wikipediaa')
from singlet.lens import SingleScopeLens, IconViewCategory, ListViewCategory
from wikipediaa import wikipediaaconfig
class WikipediaaLens(SingleScopeLens):
wiki = "http://en.wikipedia.org"
def wikipedia_query(self,search):
try:
search = search.replace(" ", "|")
url = ("%s/w/api.php?action=opensearch&limit=25&format=json&search=%s" % (self.wiki, search))
results = simplejson.loads(urllib2.urlopen(url).read())
print "Searching Wikipedia"
return results[1]
except (IOError, KeyError, urllib2.URLError, urllib2.HTTPError, simplejson.JSONDecodeError):
print "Error : Unable to search Wikipedia"
return []
def search(self, search, results):
for article in self.wikipedia_query(search):
results.append("%s/wiki/%s" % (self.wiki, article),
"http://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png",
self.articles_category,
"text/html",
article,
"Wikipedia Article",
"%s/wiki/%s" % (self.wiki, article))
pass
class Meta:
name = 'Wikipedia'
description = 'Wikipedia Lens'
search_hint = 'Search Wikipedia'
icon = 'wikipedia.svg'
search_on_blank=True
# TODO: Add your categories
articles_category = ListViewCategory("Articles", "dialog-information-symbolic")
def search(self, search, results):
# TODO: Add your search results
results.append('https://wiki.ubuntu.com/Unity/Lenses/Singlet',
'ubuntu-logo',
self.example_category,
"text/html",
'Learn More',
'Find out how to write your Unity Lens',
'https://wiki.ubuntu.com/Unity/Lenses/Singlet')
pass
so .. o que posso alterar na edição?
(se alguém me der todo o arquivo de edição editado eu aprecio)