Description:
fixed import error (thanks K.Siththa)
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r274:25b80877ebce - - 1 file changed: 2 inserted, 0 deleted
@@ -100,52 +100,54 | |||
|
100 | 100 | in_filename = "#{dirname}/#{test_num}.in" |
|
101 | 101 | sol_filename = "#{dirname}/#{test_num}.sol" |
|
102 | 102 | |
|
103 | 103 | break if not FileTest.exists? sol_filename |
|
104 | 104 | |
|
105 | 105 | test_pair = TestPair.new(:input => open(in_filename).read, |
|
106 | 106 | :solution => open(sol_filename).read, |
|
107 | 107 | :problem => @problem) |
|
108 | 108 | break if not test_pair.save |
|
109 | 109 | |
|
110 | 110 | test_num += 1 |
|
111 | 111 | end |
|
112 | 112 | return test_num > 1 |
|
113 | 113 | end |
|
114 | 114 | |
|
115 | 115 | def import_problem_description(dirname) |
|
116 | 116 | html_files = Dir["#{dirname}/*.html"] |
|
117 | 117 | markdown_files = Dir["#{dirname}/*.md"] + Dir["#{dirname}/*.markdown"] |
|
118 | 118 | if (html_files.length != 0) or (markdown_files.length != 0) |
|
119 | 119 | description = @problem.description || Description.new |
|
120 | 120 | |
|
121 | 121 | if html_files.length != 0 |
|
122 | 122 | filename = html_files[0] |
|
123 | 123 | description.markdowned = false |
|
124 | 124 | else |
|
125 | 125 | filename = markdown_files[0] |
|
126 | 126 | description.markdowned = true |
|
127 | 127 | end |
|
128 | 128 | |
|
129 | 129 | description.body = open(filename).read |
|
130 | 130 | description.save |
|
131 | 131 | @problem.description = description |
|
132 | 132 | @problem.save |
|
133 | 133 | return "\nProblem description imported from #{filename}." |
|
134 | 134 | else |
|
135 | 135 | return '' |
|
136 | 136 | end |
|
137 | 137 | end |
|
138 | 138 | |
|
139 | 139 | def import_problem_pdf(dirname) |
|
140 | 140 | pdf_files = Dir["#{dirname}/*.pdf"] |
|
141 | 141 | if pdf_files.length != 0 |
|
142 | 142 | filename = pdf_files[0] |
|
143 | 143 | out_filename = "#{Problem.download_file_basedir}/#{@problem.name}.pdf" |
|
144 | 144 | File.rename(filename, out_filename) |
|
145 | 145 | @problem.description_filename = "#{@problem.name}.pdf" |
|
146 | 146 | @problem.save |
|
147 | 147 | return "\nProblem pdf imported from #{filename}." |
|
148 | + else | |
|
149 | + return "" | |
|
148 | 150 | end |
|
149 | 151 | end |
|
150 | 152 | |
|
151 | 153 | end |
You need to be logged in to leave comments.
Login now