Commits

Henning Schröder committed 7fba429

fixes

Comments (0)

Files changed (3)

sourceindex/index.py

 import parser
 
 
+
+
+# TODO: create two indexes: global and local
+
 # TODO: add zipped packages
-
 class Indexer(object):
 
 

sourceindex/models.py

 
 from whoosh.index import create_in
 from whoosh.fields import Schema, TEXT, ID, KEYWORD, NUMERIC
-
+from whoosh.analysis import NgramWordAnalyzer
 
 # for fulltext search in comments and doc-strings
 comments_schema = Schema(
 	comments=TEXT)
 
 
+analyzer = NgramWordAnalyzer()
+name_field = TEXT(analyzer=analyzer, phrase=False)
+
+	
 # for name search
 name_schema = Schema(
 	filename=ID(stored=True), 

sourceindex/parser.py

 
 def parse(filename):
 	prj = project.NoProject()
+	prj.root = None  # os.path.dirname(filename)
 	pyc = pycore.PyCore(prj)
 	#resource = resources.File(prj, filename)
 	#if resource.is_folder():
 def find_errors(pymodule):
 	from rope.base import ast
 	from rope.contrib.finderrors import  _BadAccessFinder
-    finder = _BadAccessFinder(pymodule)
-    ast.walk(pymodule.get_ast(), finder)
-    return finder.errors
+	finder = _BadAccessFinder(pymodule)
+	ast.walk(pymodule.get_ast(), finder)
+	return finder.errors
 
 
 
-def parse_scope(scope):
+def parse_scope(scope, depth=0):
 	kind = scope.get_kind()
 	pyobj = scope.pyobject
 	if kind == "Function":
 				if ast:
 					yield "global", "", name, ast().lineno
 	for child in scope.get_scopes():
-		for item in parse_scope(child):
+		for item in parse_scope(child, depth+1):
 			yield item
 
 
 
 
 if __name__ == "__main__":
+	print list(parse("/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_number.py"))
+	raise SystemExit
 	std = stdlib_path()
 	print std
 	mods = list(modules(std))