changeset 4981:f1d1d8105d52

Xapian2009: pep8 fixes.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Thu, 06 Aug 2009 18:13:26 +0200
parents d43af366f10a
children b78a768f142b
files MoinMoin/search/Xapian.py MoinMoin/search/__init__.py MoinMoin/search/_tests/test_search.py MoinMoin/search/builtin.py MoinMoin/search/queryparser.py MoinMoin/search/results.py
diffstat 6 files changed, 31 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/Xapian.py	Thu Aug 06 17:37:44 2009 +0200
+++ b/MoinMoin/search/Xapian.py	Thu Aug 06 18:13:26 2009 +0200
@@ -25,6 +25,7 @@
 
 class UnicodeQuery(Query):
     """ Xapian query object which automatically encodes unicode strings """
+
     def __init__(self, *args, **kwargs):
         """
         @keyword encoding: specifiy the encoding manually (default: value of config.charset)
@@ -77,22 +78,22 @@
         self.add_field_action('attachment', STORE_CONTENT)
         self.add_field_action('mtime', INDEX_EXACT)
         self.add_field_action('revision', STORE_CONTENT)
-        self.add_field_action('revision',  INDEX_EXACT)
+        self.add_field_action('revision', INDEX_EXACT)
         self.add_field_action('mimetype ', INDEX_EXACT)
         self.add_field_action('mimetype', STORE_CONTENT)
         self.add_field_action('title', INDEX_FREETEXT, weight=5)
         self.add_field_action('content', INDEX_FREETEXT, spell=True)
-        self.add_field_action('fulltitle',  INDEX_EXACT)
+        self.add_field_action('fulltitle', INDEX_EXACT)
         self.add_field_action('fulltitle', STORE_CONTENT)
-        self.add_field_action('domain',  INDEX_EXACT)
+        self.add_field_action('domain', INDEX_EXACT)
         self.add_field_action('domain', STORE_CONTENT)
-        self.add_field_action('lang ',  INDEX_EXACT)
+        self.add_field_action('lang ', INDEX_EXACT)
         self.add_field_action('lang', STORE_CONTENT)
-        self.add_field_action('stem_lang ',  INDEX_EXACT)
-        self.add_field_action('author',  INDEX_EXACT)
-        self.add_field_action('linkto',  INDEX_EXACT)
+        self.add_field_action('stem_lang ', INDEX_EXACT)
+        self.add_field_action('author', INDEX_EXACT)
+        self.add_field_action('linkto', INDEX_EXACT)
         self.add_field_action('linkto', STORE_CONTENT)
-        self.add_field_action('category',  INDEX_EXACT)
+        self.add_field_action('category', INDEX_EXACT)
         self.add_field_action('category', STORE_CONTENT)
 
 
@@ -100,6 +101,7 @@
 ### Tokenizer
 ##############################################################################
 
+
 def getWikiAnalyzerFactory(request=None, language='en'):
     """ Returns a WikiAnalyzer instance
 
@@ -108,6 +110,7 @@
     """
     return (lambda: WikiAnalyzer(request, language))
 
+
 class WikiAnalyzer:
     """ A text analyzer for wiki syntax
 
@@ -171,7 +174,6 @@
                     for w, p in self.raw_tokenize_word(mw, mp):
                         yield (w, p)
 
-
     def raw_tokenize(self, value):
         """ Yield a stream of words from a string.
 
@@ -221,6 +223,7 @@
 ### Indexing
 #############################################################################
 
+
 class Index(BaseIndex):
 
     # XXX This is needed for a query parser. Since xappy uses
--- a/MoinMoin/search/__init__.py	Thu Aug 06 17:37:44 2009 +0200
+++ b/MoinMoin/search/__init__.py	Thu Aug 06 18:13:26 2009 +0200
@@ -16,6 +16,7 @@
 from MoinMoin.search.queryparser import QueryParser, QueryError
 from MoinMoin.search.builtin import MoinSearch, XapianSearch
 
+
 def searchPages(request, query, sort='weight', mtime=None, historysearch=None, **kw):
     """ Search the text of all pages for query.
 
--- a/MoinMoin/search/_tests/test_search.py	Thu Aug 06 17:37:44 2009 +0200
+++ b/MoinMoin/search/_tests/test_search.py	Thu Aug 06 18:13:26 2009 +0200
@@ -56,8 +56,7 @@
             ('no"', '["no""]'),
             ("'no", "[\"'no\"]"),
             ("no'", "[\"no'\"]"),
-            ('"no\'', '[""no\'"]')
-            ]:
+            ('"no\'', '[""no\'"]')]:
             result = parser.parse_query(query)
             assert str(result) == wanted
 
@@ -114,7 +113,6 @@
             for test in [simple_test]:
                 yield '%s %s' % (prefix, test.func_name), test, prefix, term
 
-
     def testTitleSearchAND(self):
         """ search: title search with AND expression """
         result = search.searchPages(self.request, u"title:Help title:Index")
--- a/MoinMoin/search/builtin.py	Thu Aug 06 17:37:44 2009 +0200
+++ b/MoinMoin/search/builtin.py	Thu Aug 06 18:13:26 2009 +0200
@@ -25,6 +25,7 @@
 # Search Engine Abstraction
 ##############################################################################
 
+
 class UpdateQueue:
     """ Represents a locked page queue on the disk
 
@@ -405,9 +406,12 @@
         from MoinMoin.security import Permissions
         from MoinMoin.logfile import editlog
         r = ScriptContext(request.url)
+
         class SecurityPolicy(Permissions):
+
             def read(self, *args, **kw):
                 return True
+
         r.user.may = SecurityPolicy(r.user)
         r.editlog = editlog.EditLog(r)
         return r
@@ -433,6 +437,7 @@
 ### Searching
 ##############################################################################
 
+
 class BaseSearch(object):
     """ A search run """
 
@@ -557,6 +562,7 @@
         logging.debug("_getHits returning %r." % hits)
         return hits
 
+
 class MoinSearch(BaseSearch):
 
     def __init__(self, request, query, sort='weight', mtime=None, historysearch=0, pages=None):
@@ -647,7 +653,7 @@
                   'wikiname': r.data['wikiname'][0],
                   'pagename': r.data['pagename'][0],
                   'attachment': r.data['attachment'][0],
-                  'revision': r.data.get('revision',[0])[0]}
+                  'revision': r.data.get('revision', [0])[0]}
                  for r in search_results]
 
         try:
--- a/MoinMoin/search/queryparser.py	Thu Aug 06 17:37:44 2009 +0200
+++ b/MoinMoin/search/queryparser.py	Thu Aug 06 18:13:26 2009 +0200
@@ -24,6 +24,7 @@
 except ImportError:
     pass
 
+
 class QueryError(ValueError):
     """ error raised for problems when parsing the query """
 
@@ -32,6 +33,7 @@
 ### query objects
 #############################################################################
 
+
 class BaseExpression:
     """ Base class for all search terms """
 
@@ -858,6 +860,7 @@
 ### Parse Query
 ##############################################################################
 
+
 class QueryParser:
     """
     Converts a String into a tree of Query objects.
--- a/MoinMoin/search/results.py	Thu Aug 06 17:37:44 2009 +0200
+++ b/MoinMoin/search/results.py	Thu Aug 06 18:13:26 2009 +0200
@@ -19,6 +19,7 @@
 ### Results
 ############################################################################
 
+
 class Match(object):
     """ Base class for all Matches (found pieces of pages).
 
@@ -227,6 +228,7 @@
 ### Search results formatting
 ############################################################################
 
+
 class SearchResults:
     """ Manage search results, supply different views
 
@@ -674,8 +676,8 @@
         """
         _ = self.request.getText
         f = self.formatter
+        querydict = wikiutil.parseQueryString(self.request.query_string)
 
-        querydict = wikiutil.parseQueryString(self.request.query_string)
         def page_url(n):
             querydict.update({'from': n * hitsPerPage})
             return self.request.page.url(self.request, querydict, escape=0)
@@ -691,10 +693,9 @@
         # previous page available
         if cur_page > 0:
             textlinks.append(''.join([
-                f.url(1, href=page_url(cur_page-1)),
-                f.text(_('Previous')),
-                f.url(0)
-            ]))
+                        f.url(1, href=page_url(cur_page-1)),
+                        f.text(_('Previous')),
+                        f.url(0)]))
         else:
             textlinks.append('')
 
@@ -715,8 +716,7 @@
             textlinks.append(''.join([
                 f.url(1, href=page_url(cur_page+1)),
                 f.text(_('Next')),
-                f.url(0)
-            ]))
+                f.url(0)]))
         else:
             textlinks.append('')