~voluntatefaber/fdximporter/fdximporter

« back to all changes in this revision

Viewing changes to FDXtoceltx.py

  • Committer: Andrea Basso
  • Date: 2011-12-07 20:44:58 UTC
  • Revision ID: voluntatefaber@gmail.com-20111207204458-rtyr8bfnt5konmpg
Inital implementation of revisions

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import zipfile
26
26
 
27
27
from script import *
 
28
from revisions import *
28
29
from project import *
29
30
from constant import *
30
31
 
31
 
inputfile = sys.argv[1]
32
 
 
 
32
try:
 
33
    inputfile = sys.argv[1]
 
34
except:
 
35
    raise ValueError('You must specify the input file.')
33
36
try:
34
37
    if sys.argv[2][-6:] == '.celtx':
35
38
        outputfile = sys.argv[2]
42
45
 
43
46
filecode = ID(3)
44
47
 
 
48
files = ['local.rdf', 'project.rdf', 'scratch-%s.html' % filecode, 'script-%s.html' % filecode]
 
49
 
45
50
f = open(inputfile, 'r')
46
51
script = Script(f.read(), filecode)
47
52
script.write()
48
53
f.close()
49
 
 
50
54
dictionary = {'all': ID(12), 'tabs': ID(12), 'proj': ID(12), \
51
55
              'mastercatalog': ID(12), 'screenplay': ID(12), \
52
56
              'scenes': ID(12), 'list_chars': ID(6), 'chars': ID(6), \
53
57
              'prj': ID(12), 'chars_number': len(script.chars), \
54
58
              'filecode': filecode}
55
 
 
 
59
revnumber = script.highestrev
56
60
script.close()
57
61
 
 
62
for n in range(int(revnumber), 0, -1):
 
63
    r = Revision(script.content, n)
 
64
    r.write()
 
65
    r.close()
 
66
    if n != 1:
 
67
        files.append('revision-%d.html' % n)
 
68
    else:
 
69
        files.append('revision.html')
 
70
 
58
71
project = Project(script, dictionary)
59
72
project.write()
60
73
 
71
84
f.close()
72
85
 
73
86
with zipfile.ZipFile('%s' % outputfile, 'w') as celtx:
74
 
    for f in ['local.rdf', 'project.rdf', 'scratch-%s.html' % filecode, 'script-%s.html' % filecode]:
 
87
    for f in files:
75
88
        celtx.write(f)
76
89
        os.remove(f)
77
90