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,38 +149,41 @@ 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):
|
for activity in json.loads(self.infoJson):
|
||||||
indexDict = {
|
indexDict = {
|
||||||
"name": "",
|
"name": "",
|
||||||
"description" : "",
|
"summary": "",
|
||||||
|
"description": "",
|
||||||
"tags": ()
|
"tags": ()
|
||||||
}
|
}
|
||||||
|
|
||||||
name = activity.get["name"]
|
name = activity.get("name")
|
||||||
if name != None:
|
if name is not None:
|
||||||
indexDict["name"] == name
|
indexDict["name"] = name
|
||||||
|
|
||||||
summary = activity.get["summary"]
|
summary = activity.get("summary")
|
||||||
if summary != None:
|
if summary is not None:
|
||||||
indexDict["summary"] = summary
|
indexDict["summary"] = summary
|
||||||
description = activity.get["description"]
|
|
||||||
if description != None:
|
description = activity.get("description")
|
||||||
indexDict["summary"] = (
|
if description is not None:
|
||||||
indexDict["summary"] + ' ' + description)
|
indexDict["description"] = 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:
|
||||||
|
tagsList = tagsString.split(';')
|
||||||
|
else:
|
||||||
|
tagsList = tagsString.split()
|
||||||
|
for tag in tagsList:
|
||||||
tag = tag.casefold().capitalize()
|
tag = tag.casefold().capitalize()
|
||||||
if tag not in tags:
|
if tag not in tags:
|
||||||
tags.append[tag]
|
tags.append(tag)
|
||||||
infoDict["tags"] = tuple(tags)
|
indexDict["tags"] = tuple(tags)
|
||||||
|
|
||||||
self.indexDictList.append(indexDict)
|
self.indexDictList.append(indexDict)
|
||||||
self.indexJs = (
|
self.indexJs = (
|
||||||
|
@ -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