--- a/web/blinkster/ldt/contentindexer.py Tue Jun 01 10:44:27 2010 +0200
+++ b/web/blinkster/ldt/contentindexer.py Tue Jun 01 19:07:23 2010 +0200
@@ -17,7 +17,7 @@
class ContentIndexer(object):
- def __init__(self, contentList, writer, decoupage_blackList = settings.DECOUPAGE_BLACKLIST):
+ def __init__(self, contentList, writer, decoupage_blackList=settings.DECOUPAGE_BLACKLIST):
self.__contentList = contentList
self.__decoupage_blacklist = decoupage_blackList
self.__writer = writer
@@ -45,7 +45,7 @@
def index_content(self, content):
- blinkster.utils.log.debug("Indexing content : "+str(content.iri_id))
+ blinkster.utils.log.debug("Indexing content : " + str(content.iri_id))
filepath = content.iri_file_path()
doc = xml.dom.minidom.parse(filepath)
doc = Ft.Xml.Domlette.ConvertDocument(doc)
@@ -57,23 +57,23 @@
res = xml.xpath.Evaluate("/iri/body/ensembles/ensemble", context=con)
for ensemble in res:
- ensembleId = ensemble.getAttributeNS(None,"id")
+ ensembleId = ensemble.getAttributeNS(None, "id")
for decoupageNode in ensemble.childNodes:
- blinkster.utils.log.debug("Indexing content decoupage : "+ repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist))
- if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage" or decoupageNode.getAttributeNS(None,"id") in self.decoupage_blacklist:
+ blinkster.utils.log.debug("Indexing content decoupage : " + repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist))
+ if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage" or decoupageNode.getAttributeNS(None, "id") in self.decoupage_blacklist:
continue
- decoupId = decoupageNode.getAttributeNS(None,"id")
+ decoupId = decoupageNode.getAttributeNS(None, "id")
res = xml.xpath.Evaluate("elements/element", decoupageNode)
for elementNode in res:
doc = lucene.Document()
- elementId = elementNode.getAttributeNS(None,"id")
- tags = elementNode.getAttributeNS(None,"tags")
- author = elementNode.getAttributeNS(None,"author")
- start_ts = int(elementNode.getAttributeNS(None,"begin"))
- duration = int(elementNode.getAttributeNS(None,"dur"))
- date_str = elementNode.getAttributeNS(None,"date")
+ elementId = elementNode.getAttributeNS(None, "id")
+ tags = elementNode.getAttributeNS(None, "tags")
+ author = elementNode.getAttributeNS(None, "author")
+ start_ts = int(elementNode.getAttributeNS(None, "begin"))
+ duration = int(elementNode.getAttributeNS(None, "dur"))
+ date_str = elementNode.getAttributeNS(None, "date")
if tags is not None:
tags.replace(",", ";")
@@ -107,18 +107,18 @@
doc.add(lucene.Field("abstract", abstract, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
doc.add(lucene.Field("all", " ".join([tags, title, abstract]), lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
- seg = Segment(content = content,
- iri_id = content.iri_id,
- ensemble_id = ensembleId,
- cutting_id = decoupId,
- element_id = elementId,
- tags = tags,
- title = title,
- abstract = abstract,
- duration = duration,
- author = author,
- start_ts = start_ts,
- date = date_str)
+ seg = Segment(content=content,
+ iri_id=content.iri_id,
+ ensemble_id=ensembleId,
+ cutting_id=decoupId,
+ element_id=elementId,
+ tags=tags,
+ title=title,
+ abstract=abstract,
+ duration=duration,
+ author=author,
+ start_ts=start_ts,
+ date=date_str)
seg.save()
self.__writer.addDocument(doc)
@@ -128,7 +128,7 @@
class ProjectIndexer(object):
- def __init__(self, projectList, writer, decoupage_blackList = settings.DECOUPAGE_BLACKLIST):
+ def __init__(self, projectList, writer, decoupage_blackList=settings.DECOUPAGE_BLACKLIST):
self.__projectList = projectList
self.__decoupage_blacklist = decoupage_blackList
self.__writer = writer
@@ -156,7 +156,7 @@
def index_project(self, project):
- blinkster.utils.log.debug("Indexing project : "+str(project.iri_id))
+ blinkster.utils.log.debug("Indexing project : " + str(project.iri_id))
doc = xml.dom.minidom.parseString(project.ldt)
doc = Ft.Xml.Domlette.ConvertDocument(doc)
@@ -166,25 +166,25 @@
res = xml.xpath.Evaluate("/iri/annotations/content", context=con)
for content in res:
- contentId = content.getAttributeNS(None,"id")
+ contentId = content.getAttributeNS(None, "id")
ensembleId = "ens_perso"
for decoupageNode in content.childNodes:
- blinkster.utils.log.debug("Indexing content decoupage : "+ repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist))
- if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage" or decoupageNode.getAttributeNS(None,"id") in self.decoupage_blacklist:
+ blinkster.utils.log.debug("Indexing content decoupage : " + repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist))
+ if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage" or decoupageNode.getAttributeNS(None, "id") in self.decoupage_blacklist:
continue
- decoupId = decoupageNode.getAttributeNS(None,"id")
+ decoupId = decoupageNode.getAttributeNS(None, "id")
res = xml.xpath.Evaluate("elements/element", decoupageNode)
for elementNode in res:
doc = lucene.Document()
- elementId = elementNode.getAttributeNS(None,"id")
- tags = elementNode.getAttributeNS(None,"tags")
- author = elementNode.getAttributeNS(None,"author")
- start_ts = int(elementNode.getAttributeNS(None,"begin"))
- duration = int(elementNode.getAttributeNS(None,"dur"))
- date_str = elementNode.getAttributeNS(None,"date")
+ elementId = elementNode.getAttributeNS(None, "id")
+ tags = elementNode.getAttributeNS(None, "tags")
+ author = elementNode.getAttributeNS(None, "author")
+ start_ts = int(elementNode.getAttributeNS(None, "begin"))
+ duration = int(elementNode.getAttributeNS(None, "dur"))
+ date_str = elementNode.getAttributeNS(None, "date")
if tags is not None:
tags.replace(",", ";")
@@ -221,21 +221,21 @@
doc.add(lucene.Field("all", " ".join([tags, title, abstract]), lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
try:
- content = Content.objects.get(iri_id = contentId)
- seg = Segment( project_obj = project,
- content = content,
- project_id = project.ldt_id,
- iri_id = contentId,
- ensemble_id = ensembleId,
- cutting_id = decoupId,
- element_id = elementId,
- tags = tags,
- title = title,
- abstract = abstract,
- duration = duration,
- author = author,
- start_ts = start_ts,
- date = date_str)
+ content = Content.objects.get(iri_id=contentId)
+ seg = Segment(project_obj=project,
+ content=content,
+ project_id=project.ldt_id,
+ iri_id=contentId,
+ ensemble_id=ensembleId,
+ cutting_id=decoupId,
+ element_id=elementId,
+ tags=tags,
+ title=title,
+ abstract=abstract,
+ duration=duration,
+ author=author,
+ start_ts=start_ts,
+ date=date_str)
seg.save()
except:
blinkster.utils.log.error("unable to store segment")