Description:
removed extra puts in testdata import
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r239:b65b6924abe8 - - 1 file changed: 0 inserted, 2 deleted
@@ -54,86 +54,84 | |||
|
54 | 54 | Dir.mkdir extract_dir |
|
55 | 55 | rescue Errno::EEXIST |
|
56 | 56 | end |
|
57 | 57 | |
|
58 | 58 | if ext=='.tar.gz' or ext=='.tgz' |
|
59 | 59 | cmd = "tar -zxvf #{testdata_filename} -C #{extract_dir}" |
|
60 | 60 | elsif ext=='.tar' |
|
61 | 61 | cmd = "tar -xvf #{testdata_filename} -C #{extract_dir}" |
|
62 | 62 | elsif ext=='.zip' |
|
63 | 63 | cmd = "unzip -o #{testdata_filename} -d #{extract_dir}" |
|
64 | 64 | else |
|
65 | 65 | return nil |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | system(cmd) |
|
69 | 69 | |
|
70 | 70 | files = Dir["#{extract_dir}/**/*1*.in"] |
|
71 | 71 | return nil if files.length==0 |
|
72 | 72 | |
|
73 | 73 | return File.dirname(files[0]) |
|
74 | 74 | end |
|
75 | 75 | |
|
76 | 76 | def save_testdata_file(tempfile) |
|
77 | 77 | ext = TestdataImporter.long_ext(tempfile.original_filename) |
|
78 | 78 | testdata_filename = File.join(Dir.tmpdir,"#{@problem.name}#{ext}") |
|
79 | 79 | |
|
80 | 80 | return nil if tempfile=="" |
|
81 | 81 | |
|
82 | 82 | if tempfile.instance_of?(Tempfile) |
|
83 | 83 | tempfile.close |
|
84 | 84 | FileUtils.move(tempfile.path,testdata_filename) |
|
85 | 85 | else |
|
86 | 86 | File.open(testdata_filename, "wb") do |f| |
|
87 | 87 | f.write(tempfile.read) |
|
88 | 88 | end |
|
89 | 89 | end |
|
90 | 90 | |
|
91 | 91 | return testdata_filename |
|
92 | 92 | end |
|
93 | 93 | |
|
94 | 94 | def import_test_pairs(dirname) |
|
95 | 95 | test_num = 1 |
|
96 | 96 | while FileTest.exists? "#{dirname}/#{test_num}.in" |
|
97 | 97 | in_filename = "#{dirname}/#{test_num}.in" |
|
98 | 98 | sol_filename = "#{dirname}/#{test_num}.sol" |
|
99 | 99 | |
|
100 | 100 | break if not FileTest.exists? sol_filename |
|
101 | 101 | |
|
102 | - puts "#{dirname}" | |
|
103 | - | |
|
104 | 102 | test_pair = TestPair.new(:input => open(in_filename).read, |
|
105 | 103 | :solution => open(sol_filename).read, |
|
106 | 104 | :number => test_num, |
|
107 | 105 | :problem => @problem) |
|
108 | 106 | break if not test_pair.save |
|
109 | 107 | |
|
110 | 108 | test_num += 1 |
|
111 | 109 | end |
|
112 | 110 | return test_num > 1 |
|
113 | 111 | end |
|
114 | 112 | |
|
115 | 113 | def import_problem_description(dirname) |
|
116 | 114 | html_files = Dir["#{dirname}/*.html"] |
|
117 | 115 | markdown_files = Dir["#{dirname}/*.md"] + Dir["#{dirname}/*.markdown"] |
|
118 | 116 | if (html_files.length != 0) or (markdown_files.length != 0) |
|
119 | 117 | description = @problem.description || Description.new |
|
120 | 118 | |
|
121 | 119 | if html_files.length != 0 |
|
122 | 120 | filename = html_files[0] |
|
123 | 121 | description.markdowned = false |
|
124 | 122 | else |
|
125 | 123 | filename = markdown_files[0] |
|
126 | 124 | description.markdowned = true |
|
127 | 125 | end |
|
128 | 126 | |
|
129 | 127 | description.body = open(filename).read |
|
130 | 128 | description.save |
|
131 | 129 | @problem.description = description |
|
132 | 130 | @problem.save |
|
133 | 131 | return "\nProblem description imported from #{filename}." |
|
134 | 132 | else |
|
135 | 133 | return '' |
|
136 | 134 | end |
|
137 | 135 | end |
|
138 | 136 | |
|
139 | 137 | end |
You need to be logged in to leave comments.
Login now