PyNLNindexer
Views:
The NLN Materials. Wonderful stuff but who had a proper SCORM compliant web app to run them in? At a six form college? This script was used to help build an html index page for and the materials. Someone else wrote a far more clever program to examine each nln material and wrap it in html so it could stand alone.
this is utterly broken by the way.
from xml.dom import minidom
import os
import sys
catalogue={}
def getTitle(manifest):
xmldoc=minidom.parse(manifest).documentElement
title=xmldoc.getElementsByTagName('imsmd:title')
title=title.item(0).getElementsByTagName('imsmd:langstring')
title=title.item(0).childNodes[0]
title=title.toxml()
return title
def getArea(manifest):
xmldoc=minidom.parse(manifest).documentElement
area=xmldoc.getElementsByTagName('imsmd:classification')
area=area.item(0).getElementsByTagName('imsmd:taxon')
area=area.item(0).getElementsByTagName('imsmd:langstring')
area=area.item(0).childNodes[1]
area=area.toxml()
return area
def getDepartment(manifest):
xmldoc=minidom.parse(manifest).documentElement
department=xmldoc.getElementsByTagName('imsmd:classification')
department=department.item(0).getElementsByTagName('imsmd:taxon')
department=department.item(0).getElementsByTagName('imsmd:langstring')
department=department.item(0).childNodes[2]
department=department.toxml()
return department
def findManifest(searchPath):
for item in os.listdir(searchPath):
if os.path.isdir(searchPath + '/' + item + '/'):
findManifest(searchPath + '/' + item + '/')
if item == 'imsmanifest.xml':
title=getTitle(searchPath + '/' + item + '/')
area=getArea(searchPath + '/' + item + '/')
department=getDepartment(searchPath + '/' + item + '/')
catalogue.append([searchPath,title])
def main(startPath):
findManifest(startPath)
main('/var/www/vhosts/nln/Catering, Food, Leisure Services, Tourism/Catering Operations')
