Simplified extractData.generateIndex() logic. Tags are casefolded and capitalized than checked for duplicate entries
This commit is contained in:
parent
c10fedcd44
commit
ea5fda4de1
@ -24,7 +24,6 @@ along with SAAS. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import sys
|
import sys
|
||||||
from urllib.parse import quote as strToHtmlFmt
|
from urllib.parse import quote as strToHtmlFmt
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -84,7 +83,7 @@ class extractData:
|
|||||||
infoDict = self.extractActivityInfo(infoFiles[0], bundle)
|
infoDict = self.extractActivityInfo(infoFiles[0], bundle)
|
||||||
self.bundlesInfoList.append(infoDict)
|
self.bundlesInfoList.append(infoDict)
|
||||||
|
|
||||||
# FIXME: create seprate function for it
|
# FIXME: create separate function for it
|
||||||
# extract and copy icon
|
# extract and copy icon
|
||||||
activityName = infoDict.get("name")
|
activityName = infoDict.get("name")
|
||||||
if type(activityName) == str:
|
if type(activityName) == str:
|
||||||
@ -106,8 +105,6 @@ class extractData:
|
|||||||
self.iconErrorBundles.append(bundlePath)
|
self.iconErrorBundles.append(bundlePath)
|
||||||
|
|
||||||
bundle.close()
|
bundle.close()
|
||||||
# FIXME: uncomment below function.
|
|
||||||
# Disabled sometime during development as time consuming
|
|
||||||
self.copyBundle(bundlePath, activityName)
|
self.copyBundle(bundlePath, activityName)
|
||||||
bundle.close()
|
bundle.close()
|
||||||
|
|
||||||
@ -152,45 +149,48 @@ class extractData:
|
|||||||
be created for it.
|
be created for it.
|
||||||
appends keys rather than replacing where multiple map to same
|
appends keys rather than replacing where multiple map to same
|
||||||
"""
|
"""
|
||||||
# FIXME: Simplify logic: replace str, tuple, list etc. with 'string' & 'array'
|
def generateIndex(self):
|
||||||
def generateIndex(self)
|
for activity in json.loads(self.infoJson):
|
||||||
|
indexDict = {
|
||||||
|
"name": "",
|
||||||
|
"summary": "",
|
||||||
|
"description": "",
|
||||||
|
"tags": ()
|
||||||
|
}
|
||||||
|
|
||||||
for activity in json.loads(self.infoJson):
|
name = activity.get("name")
|
||||||
indexDict = {
|
if name is not None:
|
||||||
"name": "",
|
indexDict["name"] = name
|
||||||
"description" : "",
|
|
||||||
"tags": ()
|
|
||||||
}
|
|
||||||
|
|
||||||
name = activity.get["name"]
|
summary = activity.get("summary")
|
||||||
if name != None:
|
if summary is not None:
|
||||||
indexDict["name"] == name
|
indexDict["summary"] = summary
|
||||||
|
|
||||||
summary = activity.get["summary"]
|
description = activity.get("description")
|
||||||
if summary != None:
|
if description is not None:
|
||||||
indexDict["summary"] = summary
|
indexDict["description"] = description
|
||||||
description = activity.get["description"]
|
|
||||||
if description != None:
|
|
||||||
indexDict["summary"] = (
|
|
||||||
indexDict["summary"] + ' ' + description)
|
|
||||||
|
|
||||||
tags = []
|
tags = []
|
||||||
tagsKeys = ["tag", "tags", "category", "categories"]
|
tagsKeys = ["tag", "tags", "category", "categories"]
|
||||||
for key in tagsKeys:
|
for key in tagsKeys:
|
||||||
tagsString = activity.get[tag]
|
tagsString = activity.get(key)
|
||||||
if tagsString != None:
|
if tagsString is not None:
|
||||||
for tag in tagString:
|
if tagsString.find(';') != -1:
|
||||||
tag = tag.casefold().capitalize()
|
tagsList = tagsString.split(';')
|
||||||
if tag not in tags:
|
else:
|
||||||
tags.append[tag]
|
tagsList = tagsString.split()
|
||||||
infoDict["tags"] = tuple(tags)
|
for tag in tagsList:
|
||||||
|
tag = tag.casefold().capitalize()
|
||||||
|
if tag not in tags:
|
||||||
|
tags.append(tag)
|
||||||
|
indexDict["tags"] = tuple(tags)
|
||||||
|
|
||||||
self.indexDictList.append(indexDict)
|
self.indexDictList.append(indexDict)
|
||||||
self.indexJs = (
|
self.indexJs = (
|
||||||
"search.assignIndex(" +
|
"search.assignIndex(" +
|
||||||
json.dumps(self.indexDictList, indent=4) +
|
json.dumps(self.indexDictList, indent=4) +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
||||||
def generateInfoJson(self):
|
def generateInfoJson(self):
|
||||||
self.infoJson = json.dumps(self.bundlesInfoList, indent=4)
|
self.infoJson = json.dumps(self.bundlesInfoList, indent=4)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
def CallFuncInDir(Directory, Function, *args, **kwArgs):
|
def CallFuncInDir(Directory, Function, *args, **kwArgs):
|
||||||
|
Loading…
Reference in New Issue
Block a user