Skip to content

Commit

Permalink
improves fixers for #166 #170 and #195
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Jul 19, 2021
1 parent 95847c7 commit 3e0ab5b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
4 changes: 3 additions & 1 deletion migration/ormigrate/fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,12 @@ def getRatingFromWikiFile(self,wikiFile:WikiFile)->PageRating:
rating.set(arating.pain,arating.reason,arating.hint)
return rating

def prepareWikiFileRating(self,wikiFile,templateName):
def prepareWikiFileRating(self,wikiFile,templateName=None):
'''
prepare the rating of an entity record directly from the wikiFile
'''
if templateName is None:
templateName=self.templateName
# get the markup
wikiText=str(wikiFile)
# retrieve the name/value list
Expand Down
1 change: 0 additions & 1 deletion migration/ormigrate/issue166_cfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from wikifile.wikiFile import WikiFile
from wikifile.wikiRender import WikiRender


class WikiCFPIDFixer(PageFixer):
'''
see purpose and issue
Expand Down
7 changes: 5 additions & 2 deletions migration/ormigrate/issue170_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@author: wf
'''
from ormigrate.fixer import PageFixer
from ormigrate.fixer import PageFixer,PageFixerManager
from ormigrate.rating import Rating,RatingType
from openresearch.openresearch import OpenResearch
import yaml
Expand Down Expand Up @@ -48,4 +48,7 @@ def getRating(cls,entityRecord):
else:
return Rating(7,RatingType.invalid,'last edited by unrated curator')
else:
return Rating(10,RatingType.missing,'bug: lastEditor not set')
return Rating(10,RatingType.missing,'bug: lastEditor not set')

if __name__ == "__main__":
PageFixerManager.runCmdLine([CurationQualityChecker])
16 changes: 9 additions & 7 deletions migration/ormigrate/issue195_biblographic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'''
@author: mk
'''
from ormigrate.rating import Rating,RatingType
from ormigrate.fixer import PageFixer
from ormigrate.fixer import PageFixer,PageFixerManager
from wikifile.wikiRender import WikiFile
from ormigrate.rating import PageRating,RatingType

Expand Down Expand Up @@ -30,13 +29,16 @@ def getRatingFromWikiFile(self,wikiFile:WikiFile)->PageRating:
'''
# prepare rating
wikiText,_eventDict,rating=self.prepareWikiFileRating(wikiFile,"Event")
wikiText,_eventDict,rating=self.prepareWikiFileRating(wikiFile)
hasBiblographic = "|has Bibliography=" in wikiText
hasProceedings = "|has Proceedings Bibliography=" in wikiText
if hasProceedings:
painrating = rating.set(7, RatingType.ok,f'Has Proceedings Bibliography field exists which is not defined as a property in OR')
rating.set(7, RatingType.ok,f'Has Proceedings Bibliography field exists which is not defined as a property in OR')
elif hasBiblographic:
painrating = rating.set(5, RatingType.ok,f'Has Bibliography field exists which is defined as a property in OR but is not used properly')
rating.set(5, RatingType.ok,f'Has Bibliography field exists which is defined as a property in OR but is not used properly')
else:
painrating = rating.set(1, RatingType.ok, f'No unused Bibliography fields found in event')
return painrating
rating.set(1, RatingType.ok, f'No unused Bibliography fields found in event')
return rating

if __name__ == "__main__":
PageFixerManager.runCmdLine([BiblographicFieldFixer])
20 changes: 17 additions & 3 deletions migration/tests/testIssue195_BibliographicFields.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self):
self.template="Event series"


def testRating(self):
def testRatingOfEventSeries(self):
'''
test the rating
'''
Expand All @@ -28,9 +28,23 @@ def testRating(self):
counters=self.getRatingCounters(pageTitleList)
painCounter=counters["pain"]
if pageTitleList is None:
self.assertTrue(painCounter[10]>9000)
self.assertTrue(painCounter[7]>30)
else:
self.assertEqual(1,painCounter[1])
self.assertEqual(1,painCounter[7])

def testRatingOfEvent(self):
'''
test the rating
'''
self.template="Event"
pageTitleLists=self.getPageTitleLists("Web3D 2019")
for pageTitleList in pageTitleLists:
counters=self.getRatingCounters(pageTitleList)
painCounter=counters["pain"]
if pageTitleList is None:
self.assertTrue(painCounter[7]>300)
else:
self.assertEqual(1,painCounter[7])


if __name__ == "__main__":
Expand Down

0 comments on commit 3e0ab5b

Please sign in to comment.