Skip to content

Commit

Permalink
added limit param to wikiFile extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
tholzheim committed Mar 14, 2022
1 parent f615ad7 commit 6dcc200
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wikifile/wikiFileManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def exportWikiSonToLOD(self, pageTitels: list, wikiSonName: str, pageTitleKey: s
return lod

@classmethod
def convertWikiFilesToLOD(cls, wikiFiles: list, templateName: str):
def convertWikiFilesToLOD(cls, wikiFiles: list, templateName: str, limit:int=None):
'''
converts the given wikiFiles to list of dicts
by extracting the given templateName from the wikiPage corresponding to
Expand All @@ -179,6 +179,7 @@ def convertWikiFilesToLOD(cls, wikiFiles: list, templateName: str):
Args:
wikiFiles(list): pageTitles to convert to list of dict
templateName(str): Name of the template/entity/WikiSon object that should be extracted
limit(int): limit the number of converted records
Returns:
list: a list of dicts with the content
Expand All @@ -193,6 +194,9 @@ def convertWikiFilesToLOD(cls, wikiFiles: list, templateName: str):
if pageTitle is not None:
wikiSonEntity['pageTitle']= pageTitle
lod.append(wikiSonEntity)
if limit is not None:
if len(lod) >= limit:
break
return lod

def pagesListToDict(self, data: list, titleKey: str = "pageTitle", removeKey:bool=True) -> dict:
Expand Down

0 comments on commit 6dcc200

Please sign in to comment.