~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/util.py

  • Committer: dcoles
  • Date: 2008-03-10 06:11:51 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:682
Natural Language Tool Kit (nltk) for student code

setup.py: copy '/usr/share/nltk' into jail
d/s/install_proc.txt: How to download and install NLTK
d/dependencies.txt: Added NLTK as a student code dependancy

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        self.message = message
48
48
        self.args = (httpcode, message)
49
49
 
50
 
class IVLEJailError(Exception):
51
 
    """
52
 
    This exception indicates an error that occurred inside an IVLE CGI script
53
 
    inside the jail. It should never be raised directly - only by the 
54
 
    interpreter.
55
 
 
56
 
    Information will be retrieved from it, and then treated as a normal
57
 
    error.
58
 
    """
59
 
    def __init__(self, type_str, message, info):
60
 
        self.type_str = type_str
61
 
        self.message = message
62
 
        self.info = info
63
 
 
64
50
def make_path(path):
65
51
    """Given a path relative to the IVLE root, makes the path relative to the
66
52
    site root using conf.root_dir. This path can be used in URLs sent to the
124
110
    else:
125
111
        return tuple(splitpath)
126
112
 
127
 
def open_exercise_file(exercisename):
128
 
    """Given an exercise name, opens the corresponding XML file for reading.
129
 
    Returns None if the exercise file was not found.
130
 
    (For tutorials / worksheets).
131
 
    """
132
 
    # First normalise the path
133
 
    exercisename = os.path.normpath(exercisename)
134
 
    # Now if it begins with ".." or separator, then it's illegal
135
 
    if exercisename.startswith("..") or exercisename.startswith(os.sep):
136
 
        exercisefile = None
137
 
    else:
138
 
        exercisefile = os.path.join(conf.exercises_base, exercisename)
139
 
 
140
 
    try:
141
 
        return open(exercisefile)
142
 
    except (TypeError, IOError):    # TypeError if exercisefile == None
143
 
        return None
144
 
 
145
113
# Initialise mime types library
146
114
mimetypes.init()
147
115
for (ext, mimetype) in conf.mimetypes.additional_mime_types.items():