Commits

Matt Chaput committed 0c3ab09

Commented out uses of "print" keyword in experimental code to allow installation on Python 3.x.
Minor fixes.

Comments (0)

Files changed (4)

src/whoosh/automata/glob.py

 _RANGE = 4
 _END = 5
 
+
 def parse_glob(pattern, _glob_multi=b("*"), _glob_single=b("?"),
                _glob_range1=b("["), _glob_range2=b("]"),
                _glob_range_not=b("!")):
     return emptybytes.join(output)
 
 
-if __name__ == "__main__":
-    from whoosh import index, query
-    from whoosh.filedb.filestore import RamStorage
-    from whoosh.automata import fst
-    from whoosh.util.testing import timing
-
-    st = RamStorage()
-    gw = fst.GraphWriter(st.create_file("test"))
-    gw.start_field("test")
-    for key in ["aaaa", "aaab", "aabb", "abbb", "babb", "bbab", "bbba"]:
-        gw.insert(key)
-    gw.close()
-    gr = fst.GraphReader(st.open_file("test"))
-
-    print glob_graph_limit(gr, LO, "bbb*", gr._root)
-    print glob_graph_limit(gr, HI, "bbb*", gr._root)
-
-    ix = index.open_dir("e:/dev/src/houdini/help/index")
-    r = ix.reader()
-    gr = r._get_graph()
-    p = "?[abc]*"
-    p = "*/"
-
-    with timing():
-        q = query.Wildcard("path", p)
-        x = list(q._btexts(r))
-
-    with timing():
-        prog = parse_glob(p)
-        lo = glob_graph_limit(gr, LO, prog, address=gr.root("path"))
-        hi = glob_graph_limit(gr, HI, prog, address=gr.root("path"))
-        q = query.TermRange("path", lo, hi)
-        y = list(q._btexts(r))
-
-
+# if __name__ == "__main__":
+#     from whoosh import index, query
+#     from whoosh.filedb.filestore import RamStorage
+#     from whoosh.automata import fst
+#     from whoosh.util.testing import timing
+#
+#     st = RamStorage()
+#     gw = fst.GraphWriter(st.create_file("test"))
+#     gw.start_field("test")
+#     for key in ["aaaa", "aaab", "aabb", "abbb", "babb", "bbab", "bbba"]:
+#         gw.insert(key)
+#     gw.close()
+#     gr = fst.GraphReader(st.open_file("test"))
+#
+#     print glob_graph_limit(gr, LO, "bbb*", gr._root)
+#     print glob_graph_limit(gr, HI, "bbb*", gr._root)
+#
+#     ix = index.open_dir("e:/dev/src/houdini/help/index")
+#     r = ix.reader()
+#     gr = r._get_graph()
+#     p = "?[abc]*"
+#     p = "*/"
+#
+#     with timing():
+#         q = query.Wildcard("path", p)
+#         x = list(q._btexts(r))
+#
+#     with timing():
+#         prog = parse_glob(p)
+#         lo = glob_graph_limit(gr, LO, prog, address=gr.root("path"))
+#         hi = glob_graph_limit(gr, HI, prog, address=gr.root("path"))
+#         q = query.TermRange("path", lo, hi)
+#         y = list(q._btexts(r))
+#
+#

src/whoosh/automata/nfa.py

             raise Exception("Don't know what to do with %r" % op)
 
 
-if __name__ == "__main__":
-    from whoosh import index, query
-    from whoosh.filedb.filestore import RamStorage
-    from whoosh.automata import fst
-    from whoosh.util.testing import timing
-
-    st = RamStorage()
-    gw = fst.GraphWriter(st.create_file("test"))
-    gw.start_field("test")
-    for key in ["aaaa", "aaab", "aabb", "abbb", "babb", "bbab", "bbba"]:
-        gw.insert(key)
-    gw.close()
-    gr = fst.GraphReader(st.open_file("test"))
-
-    program = one_or_more([Lit("a")])
-    print program
-    program = fixup(program)
-    print program
-    print list(run(gr, program, gr.root("test")))
-
-    ix = index.open_dir("e:/dev/src/houdini/help/index")
-    r = ix.reader()
-    gr = r._get_graph()
-
-#    program = fixup([Any(), Any(), Any(), Any(), Any()])
-#    program = fixup(concat(zero_or_more([Any()]), [Char("/")]))
-#    with timing():
-#        x = list(run(gr, program, gr.root("path")))
-#    print len(x)
-
-    q = query.Regex("path", "^.[abc].*/$")
-    with timing():
-        y = list(q._btexts(r))
-    print len(y)
-    print y[0], y[-1]
-
-    pr = [Any()] + alt([Lit("c")], alt([Lit("b")], [Lit("a")])) + zero_or_more([Any()]) + [Lit("/")]
-    program = fixup(pr)
-#    with timing():
-#        x = list(run(gr, program, gr.root("path")))
-#    print len(x), x
-
-    with timing():
-        print "lo=", regex_limit(gr, LO, program, gr.root("path"))
-        print "hi=", regex_limit(gr, HI, program, gr.root("path"))
-
-
-
-#int
-#backtrackingvm(Inst *prog, char *input)
-#{
-#    enum { MAXTHREAD = 1000 };
-#    Thread ready[MAXTHREAD];
-#    int nready;
-#    Inst *pc;
-#    char *sp;
+# if __name__ == "__main__":
+#     from whoosh import index, query
+#     from whoosh.filedb.filestore import RamStorage
+#     from whoosh.automata import fst
+#     from whoosh.util.testing import timing
 #
-#    /* queue initial thread */
-#    ready[0] = thread(prog, input);
-#    nready = 1;
+#     st = RamStorage()
+#     gw = fst.GraphWriter(st.create_file("test"))
+#     gw.start_field("test")
+#     for key in ["aaaa", "aaab", "aabb", "abbb", "babb", "bbab", "bbba"]:
+#         gw.insert(key)
+#     gw.close()
+#     gr = fst.GraphReader(st.open_file("test"))
 #
-#    /* run threads in stack order */
-#    while(nready > 0){
-#        --nready;  /* pop state for next thread to run */
-#        pc = ready[nready].pc;
-#        sp = ready[nready].sp;
-#        for(;;){
-#            switch(pc->opcode){
-#            case Char:
-#                if(*sp != pc->c)
-#                    goto Dead;
-#                pc++;
-#                sp++;
-#                continue;
-#            case Match:
-#                return 1;
-#            case Jmp:
-#                pc = pc->x;
-#                continue;
-#            case Split:
-#                if(nready >= MAXTHREAD){
-#                    fprintf(stderr, "regexp overflow");
-#                    return -1;
-#                }
-#                /* queue new thread */
-#                ready[nready++] = thread(pc->y, sp);
-#                pc = pc->x;  /* continue current thread */
-#                continue;
-#            }
-#        }
-#    Dead:;
-#    }
-#    return 0;
-#}
-
-
+#     program = one_or_more([Lit("a")])
+#     print program
+#     program = fixup(program)
+#     print program
+#     print list(run(gr, program, gr.root("test")))
+#
+#     ix = index.open_dir("e:/dev/src/houdini/help/index")
+#     r = ix.reader()
+#     gr = r._get_graph()
+#
+# #    program = fixup([Any(), Any(), Any(), Any(), Any()])
+# #    program = fixup(concat(zero_or_more([Any()]), [Char("/")]))
+# #    with timing():
+# #        x = list(run(gr, program, gr.root("path")))
+# #    print len(x)
+#
+#     q = query.Regex("path", "^.[abc].*/$")
+#     with timing():
+#         y = list(q._btexts(r))
+#     print len(y)
+#     print y[0], y[-1]
+#
+#     pr = [Any()] + alt([Lit("c")], alt([Lit("b")], [Lit("a")])) + zero_or_more([Any()]) + [Lit("/")]
+#     program = fixup(pr)
+# #    with timing():
+# #        x = list(run(gr, program, gr.root("path")))
+# #    print len(x), x
+#
+#     with timing():
+#         print "lo=", regex_limit(gr, LO, program, gr.root("path"))
+#         print "hi=", regex_limit(gr, HI, program, gr.root("path"))
+#
+#
+#
+# #int
+# #backtrackingvm(Inst *prog, char *input)
+# #{
+# #    enum { MAXTHREAD = 1000 };
+# #    Thread ready[MAXTHREAD];
+# #    int nready;
+# #    Inst *pc;
+# #    char *sp;
+# #
+# #    /* queue initial thread */
+# #    ready[0] = thread(prog, input);
+# #    nready = 1;
+# #
+# #    /* run threads in stack order */
+# #    while(nready > 0){
+# #        --nready;  /* pop state for next thread to run */
+# #        pc = ready[nready].pc;
+# #        sp = ready[nready].sp;
+# #        for(;;){
+# #            switch(pc->opcode){
+# #            case Char:
+# #                if(*sp != pc->c)
+# #                    goto Dead;
+# #                pc++;
+# #                sp++;
+# #                continue;
+# #            case Match:
+# #                return 1;
+# #            case Jmp:
+# #                pc = pc->x;
+# #                continue;
+# #            case Split:
+# #                if(nready >= MAXTHREAD){
+# #                    fprintf(stderr, "regexp overflow");
+# #                    return -1;
+# #                }
+# #                /* queue new thread */
+# #                ready[nready++] = thread(pc->y, sp);
+# #                pc = pc->x;  /* continue current thread */
+# #                continue;
+# #            }
+# #        }
+# #    Dead:;
+# #    }
+# #    return 0;
+# #}
+#
+#
Add a comment to this file

src/whoosh/codec/__init__.py

File contents unchanged.

src/whoosh/util/testing.py

 from contextlib import contextmanager
 
 from whoosh.filedb.filestore import FileStorage
-from whoosh.util import random_name
+from whoosh.util import now, random_name
 
 
 class TempDir(object):
     t = now()
     yield
     t = now() - t
-    print "%s: %0.06f s" % (name or '', t)
+    print("%s: %0.06f s" % (name or '', t))
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 ProjectModifiedEvent.java.
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.