fortechniqueintechnique_list:# For each unique technique we found with get_techniques()...
forprojectindata:# For every project in data, as we need to look over them all for each technique.
iftechniqueinproject['techniques_used']:# If the technique we're currently looking for is in the used techniques of the project we're iterating over.
current_techniques.append({'id':project['project_id'],'name':project['project_name']})# Create a new dict INSIDE the list with the project ID and project name.
ifsearchisnotNone:# If the search field isn't set to None..
search_results=[]# Create a list for our search results..
forprojectinresults:# For every project we've found so far..
ifsearch_fieldsisnotNoneandsearch_fields!=""andsearch!=""andsearch_fields!=['None']:# If the searchf ield is not set to None AND search_fields is not empty AND search_fields is not an empty list..
forfieldinsearch_fields:# For each field in search fields..
substring=project[field]# Save the current field in substring so we can do operations on it..
# Check types before calling lower()
ifisinstance(substring,str):
substring=substring.lower()
ifsubstring.find(search)!=-1:
substring=substring.lower()# Make case insensitive
ifsubstring.find(search)!=-1:# If found
search_results.append(project)
break
elifisinstance(substring,int):
elifisinstance(substring,int):
ifstr(substring).find(search)!=-1:
search_results.append(project)
break
elifisinstance(substring,list):
forsubsubstringinsubstring:
ifisinstance(subsubstring,str):
elifisinstance(substring,list):# If it's a list..
forsubsubstringinsubstring:# We'll need to make another substring so we can iterate over each index of the list instead of just for multiple lists.