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

« back to all changes in this revision

Viewing changes to bin/ivle-cloneworksheets

  • Committer: William Grant
  • Date: 2010-02-23 08:55:42 UTC
  • mto: This revision was merged to the branch mainline in revision 1674.
  • Revision ID: grantw@unimelb.edu.au-20100223085542-r8xw14bxxoraza51
Permit underscores in all names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
import sys
23
23
 
 
24
import ivle.config
24
25
from ivle.database import get_store, Subject, Semester, Offering, Worksheet
25
 
import ivle.worksheet
 
26
import ivle.worksheet.utils
26
27
 
27
28
def die(error):
28
29
    print >> sys.stderr, '%s: %s' % (os.path.basename(sys.argv[0]), error)
34
35
                         % os.path.basename(sys.argv[0])
35
36
    sys.exit()
36
37
 
37
 
store = get_store()
 
38
store = get_store(ivle.config.Config())
38
39
 
39
40
src = store.find(Offering,
40
41
                 Subject.code == unicode(sys.argv[1]),
53
54
if dst.worksheets.count() > 0:
54
55
    die('%r already has worksheets - doing nothing' % dst)
55
56
 
56
 
for oldws in src.worksheets:
57
 
    newws = Worksheet()
58
 
    newws.seq_no = oldws.seq_no
59
 
    newws.identifier = oldws.identifier
60
 
    newws.name = oldws.name
61
 
    newws.assessable = oldws.assessable
62
 
    newws.data = oldws.data
63
 
    newws.format = oldws.format
64
 
    newws.offering = dst
65
 
    store.add(newws)
66
 
    ivle.worksheet.update_exerciselist(newws)
 
57
dst.clone_worksheets(src)
67
58
 
68
59
print >> sys.stderr, 'copied %d worksheets from %r to %r' \
69
60
                     % (dst.worksheets.count(), src, dst)