From: gfawcett Date: Mon, 27 Dec 2010 21:58:01 +0000 (+0000) Subject: uwindsor: fetch catalogue of known courses, departments. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ca5e0ddbca24d40d1dfba2687ce296258ab46078;p=syrup%2Fmasslnc.git uwindsor: fetch catalogue of known courses, departments. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1118 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/conifer/integration/uwindsor.py b/conifer/integration/uwindsor.py index 1fc8e62..7b39dde 100644 --- a/conifer/integration/uwindsor.py +++ b/conifer/integration/uwindsor.py @@ -11,6 +11,8 @@ from xml.etree import ElementTree as ET import re import uwindsor_campus_info from memoization import memoize +import csv +import subprocess # USE_Z3950: if True, use Z39.50 for catalogue search; if False, use OpenSRF. # Don't set this value directly here: rather, if there is a valid Z3950_CONFIG @@ -25,16 +27,13 @@ def department_course_catalogue(): the departments to which they belong. Each row should be a tuple in the form: ('Department name', 'course-code', 'Course name'). """ - return [ - ('Arts','01-01-209','Ethics in the Professions'), - ('Social Work','02-47-204','Issues & Perspectives in Social Welfare'), - ('Social Work','02-47-211','Prof Comm in Gen. Social Work Practice'), - ('Social Work','02-47-336','Theory and Practice Social Work I'), - ('Social Work','02-47-361','Field Practice I - A'), - ('Social Work','02-47-362','Field Practice I - B'), - ('Social Work','02-47-370','Mothering and Motherhood'), - ('Social Work','02-47-456','Social Work and Health'), - ] + url = 'http://cleo.uwindsor.ca/graham/courses.txt.gz' + p = subprocess.Popen('curl -s %s | gunzip -c' % url, + shell=True, stdout=subprocess.PIPE) + reader = csv.reader(p.stdout) + catalogue = list(reader) + p.stdout.close() + return catalogue def term_catalogue(): """ diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index 97885ce..ace11bc 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -750,7 +750,8 @@ def highlight(text, phrase, else: return highlight_re.sub(highlighter, text) - +#---------------------------------------------------------------------- +# Activate the local integration module. if hasattr(settings, 'INTEGRATION_MODULE'): import conifer.syrup.integration