| 1 |
#!/usr/bin/env python3 |
| 2 |
import sys |
| 3 |
from os import unlink |
| 4 |
from os.path import exists, isdir |
| 5 |
from shutil import rmtree |
| 6 |
from glob import glob |
| 7 |
|
| 8 |
|
| 9 |
excluded = [] |
| 10 |
|
| 11 |
|
| 12 |
match = False |
| 13 |
for line in open('debian/copyright').read().split('\n'): |
| 14 |
if match: |
| 15 |
if len(line) == 0: |
| 16 |
break |
| 17 |
if line[0] == '#': |
| 18 |
continue |
| 19 |
excluded.extend(glob(line.strip())) |
| 20 |
elif line == 'Files-Excluded:': |
| 21 |
match = True |
| 22 |
else: |
| 23 |
continue |
| 24 |
|
| 25 |
print('Removing excluded files:') |
| 26 |
for item in excluded: |
| 27 |
if not exists(item): |
| 28 |
print('does not exist:', item, file=sys.stderr) |
| 29 |
continue |
| 30 |
print(item) |
| 31 |
if isdir(item): |
| 32 |
rmtree(item) |
| 33 |
else: |
| 34 |
unlink(item) |