Conditions | 5 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
1 | import os |
||
11 | def main(log_printer=None, section: Section=None): |
||
12 | start_path = get_config_directory(section) |
||
13 | log_printer = log_printer or LogPrinter(ConsolePrinter()) |
||
14 | |||
15 | if start_path is None: |
||
16 | return 255 |
||
17 | |||
18 | orig_files = Globbing.glob(os.path.abspath( |
||
19 | os.path.join(start_path, '**', '*.orig'))) |
||
20 | |||
21 | not_deleted = 0 |
||
22 | for ofile in orig_files: |
||
23 | log_printer.info("Deleting old backup file... " |
||
24 | + os.path.relpath(ofile)) |
||
25 | try: |
||
26 | os.remove(ofile) |
||
27 | except OSError as oserror: |
||
28 | not_deleted += 1 |
||
29 | log_printer.warn("Couldn't delete {}. {}".format( |
||
30 | os.path.relpath(ofile), oserror.strerror)) |
||
31 | |||
32 | if not_deleted: |
||
33 | log_printer.warn(str(not_deleted) + " .orig backup files could not be" |
||
34 | " deleted, possibly because you lack the permission" |
||
35 | " to do so. coala may not be able to create" |
||
36 | " backup files when patches are applied.") |
||
37 | return 0 |
||
38 |