|
22 | 22 |
|
23 | 23 | from __future__ import print_function |
24 | 24 |
|
25 | | - |
26 | 25 | import csv |
27 | 26 | import errno |
28 | 27 | import logging |
29 | 28 | import optparse |
| 29 | +import os |
30 | 30 | import sys |
31 | 31 |
|
32 | | -from os.path import exists, dirname, join, abspath, isdir, basename, expanduser |
| 32 | +from os.path import exists, dirname, join, abspath, isdir, basename, expanduser, normpath |
33 | 33 |
|
34 | 34 | from about import Collector |
35 | 35 | import genabout |
@@ -157,8 +157,8 @@ def main(parser, options, args): |
157 | 157 | input_path, output_path, component_subset_path = args |
158 | 158 |
|
159 | 159 | # TODO: need more path normalization (normpath, expanduser) |
160 | | - # input_path = abspath(input_path) |
161 | | - output_path = abspath(output_path) |
| 160 | + input_path = expanduser(normpath(input_path)) |
| 161 | + output_path = expanduser(normpath(output_path)) |
162 | 162 |
|
163 | 163 | # Add the following to solve the |
164 | 164 | # UnicodeEncodeError: 'ascii' codec can't encode character |
@@ -229,11 +229,12 @@ def main(parser, options, args): |
229 | 229 | print("Problem occurs. Attribution was not generated.") |
230 | 230 | print(e) |
231 | 231 |
|
232 | | - # Clear the log file |
233 | | - with open(join(dirname(output_path), LOG_FILENAME), 'w'): |
234 | | - pass |
| 232 | + # Remove the previous log file if exist |
| 233 | + log_path = join(dirname(output_path), LOG_FILENAME) |
| 234 | + if exists(log_path): |
| 235 | + os.remove(log_path) |
235 | 236 |
|
236 | | - file_handler = logging.FileHandler(join(dirname(output_path), LOG_FILENAME)) |
| 237 | + file_handler = logging.FileHandler(log_path) |
237 | 238 | file_logger.addHandler(file_handler) |
238 | 239 | for error_msg in errors: |
239 | 240 | logger.error(error_msg) |
|
0 commit comments