make log message more informative
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3235 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
6f689c33fe
commit
2fd20f6508
2 changed files with 8 additions and 4 deletions
|
@ -131,11 +131,13 @@ that may be identified as being candidates for classification.
|
||||||
So we are now ready to have the whole stuff run in one call.
|
So we are now ready to have the whole stuff run in one call.
|
||||||
|
|
||||||
>>> classifier.process(r1)
|
>>> classifier.process(r1)
|
||||||
|
Classifier fileclassifier: Assigning: ...
|
||||||
>>> list(sorted([c.title for c in r1.getConcepts()]))
|
>>> list(sorted([c.title for c in r1.getConcepts()]))
|
||||||
[u'Collection One', u'Contract', u'External File', u'Gerald Webb', u'im Editors']
|
[u'Collection One', u'Contract', u'External File', u'Gerald Webb', u'im Editors']
|
||||||
|
|
||||||
>>> for name in rnames[1:]:
|
>>> for name in rnames[1:]:
|
||||||
... classifier.process(resources[name])
|
... classifier.process(resources[name])
|
||||||
|
Classifier fileclassifier: Assigning: ...
|
||||||
>>> len(webbg.getResources())
|
>>> len(webbg.getResources())
|
||||||
4
|
4
|
||||||
>>> len(webbg.getResources((concepts['ownedby'],)))
|
>>> len(webbg.getResources((concepts['ownedby'],)))
|
||||||
|
@ -145,6 +147,7 @@ We can repeat the process without getting additional assignments.
|
||||||
|
|
||||||
>>> for name in rnames[1:]:
|
>>> for name in rnames[1:]:
|
||||||
... classifier.process(resources[name])
|
... classifier.process(resources[name])
|
||||||
|
Classifier fileclassifier: Already assigned: ...
|
||||||
>>> len(webbg.getResources())
|
>>> len(webbg.getResources())
|
||||||
4
|
4
|
||||||
|
|
||||||
|
|
|
@ -94,15 +94,16 @@ class Classifier(AdapterBase):
|
||||||
statement.subject = resource
|
statement.subject = resource
|
||||||
if statement.predicate is None:
|
if statement.predicate is None:
|
||||||
statement.predicate = self.defaultPredicate
|
statement.predicate = self.defaultPredicate
|
||||||
self.log('Assigning: %s %s %s' % (statement.subject.title,
|
self.assignConcept(statement.subject, object, statement.predicate)
|
||||||
statement.predicate.title, object.title), 5)
|
|
||||||
self.assignConcept(statement.subject, object,
|
|
||||||
statement.predicate)
|
|
||||||
|
|
||||||
def assignConcept(self, resource, concept, predicate):
|
def assignConcept(self, resource, concept, predicate):
|
||||||
resources = concept.getResources([predicate])
|
resources = concept.getResources([predicate])
|
||||||
if resource not in resources:
|
if resource not in resources:
|
||||||
concept.assignResource(resource, predicate)
|
concept.assignResource(resource, predicate)
|
||||||
|
message = 'Assigning: %s %s %s'
|
||||||
|
else:
|
||||||
|
message = 'Already assigned: %s %s %s'
|
||||||
|
self.log(message % (resource.title, predicate.title, concept.title), 5)
|
||||||
|
|
||||||
def log(self, message, level=5):
|
def log(self, message, level=5):
|
||||||
if level >= self.logLevel:
|
if level >= self.logLevel:
|
||||||
|
|
Loading…
Add table
Reference in a new issue