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 json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from urllib.parse import quote as strToHtmlFmt
|
||||
import zipfile
|
||||
@ -84,7 +83,7 @@ class extractData:
|
||||
infoDict = self.extractActivityInfo(infoFiles[0], bundle)
|
||||
self.bundlesInfoList.append(infoDict)
|
||||
|
||||
# FIXME: create seprate function for it
|
||||
# FIXME: create separate function for it
|
||||
# extract and copy icon
|
||||
activityName = infoDict.get("name")
|
||||
if type(activityName) == str:
|
||||
@ -106,8 +105,6 @@ class extractData:
|
||||
self.iconErrorBundles.append(bundlePath)
|
||||
|
||||
bundle.close()
|
||||
# FIXME: uncomment below function.
|
||||
# Disabled sometime during development as time consuming
|
||||
self.copyBundle(bundlePath, activityName)
|
||||
bundle.close()
|
||||
|
||||
@ -152,38 +149,41 @@ class extractData:
|
||||
be created for it.
|
||||
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": ()
|
||||
}
|
||||
|
||||
name = activity.get["name"]
|
||||
if name != None:
|
||||
indexDict["name"] == name
|
||||
name = activity.get("name")
|
||||
if name is not None:
|
||||
indexDict["name"] = name
|
||||
|
||||
summary = activity.get["summary"]
|
||||
if summary != None:
|
||||
summary = activity.get("summary")
|
||||
if summary is not None:
|
||||
indexDict["summary"] = summary
|
||||
description = activity.get["description"]
|
||||
if description != None:
|
||||
indexDict["summary"] = (
|
||||
indexDict["summary"] + ' ' + description)
|
||||
|
||||
description = activity.get("description")
|
||||
if description is not None:
|
||||
indexDict["description"] = description
|
||||
|
||||
tags = []
|
||||
tagsKeys = ["tag", "tags", "category", "categories"]
|
||||
for key in tagsKeys:
|
||||
tagsString = activity.get[tag]
|
||||
if tagsString != None:
|
||||
for tag in tagString:
|
||||
tagsString = activity.get(key)
|
||||
if tagsString is not None:
|
||||
if tagsString.find(';') != -1:
|
||||
tagsList = tagsString.split(';')
|
||||
else:
|
||||
tagsList = tagsString.split()
|
||||
for tag in tagsList:
|
||||
tag = tag.casefold().capitalize()
|
||||
if tag not in tags:
|
||||
tags.append[tag]
|
||||
infoDict["tags"] = tuple(tags)
|
||||
tags.append(tag)
|
||||
indexDict["tags"] = tuple(tags)
|
||||
|
||||
self.indexDictList.append(indexDict)
|
||||
self.indexJs = (
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
def CallFuncInDir(Directory, Function, *args, **kwArgs):
|
||||
|
Loading…
Reference in New Issue
Block a user