Matt Chaput committed 83676c9

Changed FuzzyTermNode.r() to use %r instead of %s
to avoid print decoding errors. Fixes issue #360.

Also put if debug: lines on old debug prints in the query parser to
avoid calling the repr methods on nodes unnecessarily.

Comments (0)

Files changed (2)


         prev = pos
         # Priorized list of taggers provided by the parser's plugins
         taggers = self.taggers()
-        print_debug(debug, "Taggers: %r" % taggers)
+        if debug:
+            print_debug(debug, "Taggers: %r" % taggers)
         # Define a function that will make a WordNode from the "interstitial"
         # text between matches
                                         " (%r, %s)" % (tagger, text, pos))
                     if prev < pos:
                         tween = inter(prev, pos)
-                        print_debug(debug, "Tween: %r" % tween)
+                        if debug:
+                            print_debug(debug, "Tween: %r" % tween)
-                    print_debug(debug, "Tagger: %r at %s: %r"
-                                % (tagger, pos, node))
+                    if debug:
+                        print_debug(debug, "Tagger: %r at %s: %r"
+                                    % (tagger, pos, node))
                     prev = pos = node.endchar
         # Wrap the list of nodes in a group node
         group =
-        print_debug(debug, "Tagged group: %r" % group)
+        if debug:
+            print_debug(debug, "Tagged group: %r" % group)
         return group
     def filterize(self, nodes, debug=False):
         # Call each filter in the priorized list of plugin filters
-        print_debug(debug, "Pre-filtered group: %r" % nodes)
+        if debug:
+            print_debug(debug, "Pre-filtered group: %r" % nodes)
         for f in self.filters():
-            print_debug(debug, "..Applying: %r" % f)
+            if debug:
+                print_debug(debug, "..Applying: %r" % f)
             nodes = f(self, nodes)
-            print_debug(debug, "..Result: %r" % nodes)
+            if debug:
+                print_debug(debug, "..Result: %r" % nodes)
             if nodes is None:
                 raise Exception("Filter %r did not return anything" % f)
         return nodes
             text = text.decode("latin1")
         nodes = self.process(text, debug=debug)
-        print_debug(debug, "Syntax tree: %r" % nodes)
+        if debug:
+            print_debug(debug, "Syntax tree: %r" % nodes)
         q = nodes.query(self)
         if not q:
             q = query.NullQuery
-        print_debug(debug, "Pre-normalized query: %r" % q)
+        if debug:
+            print_debug(debug, "Pre-normalized query: %r" % q)
         if normalize:
             q = q.normalize()
-            print_debug(debug, "Normalized query: %r" % q)
+            if debug:
+                print_debug(debug, "Normalized query: %r" % q)
         return q
     def parse_(self, text, normalize=True):


             self.prefix = prefix
         def r(self):
-            return "%s ~%d" % (self.text, self.maxdist)
+            return "%r ~%d" % (self.text, self.maxdist)
         def query(self, parser):
             # Use the superclass's query() method to create a FuzzyTerm query
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.