-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathskips_to_changes.py
More file actions
43 lines (31 loc) · 1.04 KB
/
Copy pathskips_to_changes.py
File metadata and controls
43 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
import argparse
import csv
import logging
import os
import sys
from typing import Tuple
from common import IncludeChange
def main():
parser = argparse.ArgumentParser(description="Make a full changes list from skips")
parser.add_argument("skips")
parser.add_argument("--verbose", action="store_true", default=False, help="Enable verbose logging.")
args = parser.parse_args()
if args.verbose:
logging.basicConfig(level=logging.DEBUG)
with open(args.skips, "r", newline="") as f:
skips = [row for row in csv.reader(f) if row]
csv_writer = csv.writer(sys.stdout)
try:
for includer, included in skips:
csv_writer.writerow((IncludeChange.REMOVE.value, 0, includer, included))
except BrokenPipeError:
devnull = os.open(os.devnull, os.O_WRONLY)
os.dup2(devnull, sys.stdout.fileno())
sys.exit(1)
return 0
if __name__ == "__main__":
try:
sys.exit(main())
except KeyboardInterrupt:
pass # Don't show the user anything