@@ -30,7 +30,7 @@ def keyword_array(keyword_line: str) -> list[str]:
30
30
i2 : int = keyword_line .rfind ('"' )
31
31
32
32
# Split into array of KEYWORDS
33
- return keyword_line [i1 :i2 ].split (' ' )
33
+ return keyword_line [i1 :i2 ].split (" " )
34
34
35
35
36
36
def keyword_line_changes (old : str , new : str ) -> KeywordChanges :
@@ -41,14 +41,20 @@ def keyword_line_changes(old: str, new: str) -> KeywordChanges:
41
41
42
42
changes : KeywordChanges = []
43
43
for tag , i1 , i2 , j1 , j2 in s .get_opcodes ():
44
- if tag == 'replace' :
45
- changes .append ((a [i1 :i2 ], b [j1 :j2 ]),)
46
- elif tag == 'delete' :
47
- changes .append ((a [i1 :i2 ], None ),)
48
- elif tag == 'insert' :
49
- changes .append ((None , b [j1 :j2 ]),)
44
+ if tag == "replace" :
45
+ changes .append (
46
+ (a [i1 :i2 ], b [j1 :j2 ]),
47
+ )
48
+ elif tag == "delete" :
49
+ changes .append (
50
+ (a [i1 :i2 ], None ),
51
+ )
52
+ elif tag == "insert" :
53
+ changes .append (
54
+ (None , b [j1 :j2 ]),
55
+ )
50
56
else :
51
- assert tag == ' equal'
57
+ assert tag == " equal"
52
58
return changes
53
59
54
60
@@ -58,34 +64,33 @@ def keyword_changes(ebuild1: str, ebuild2: str) -> Optional[KeywordChanges]:
58
64
lines2 = e2 .readlines ()
59
65
60
66
diff = difflib .unified_diff (lines1 , lines2 , n = 0 )
61
- assert next (diff ) == ' --- \n '
62
- assert next (diff ) == ' +++ \n '
67
+ assert next (diff ) == " --- \n "
68
+ assert next (diff ) == " +++ \n "
63
69
64
70
hunk : int = 0
65
- old : str = ''
66
- new : str = ''
71
+ old : str = ""
72
+ new : str = ""
67
73
68
74
for line in diff :
69
- if line .startswith (' @@ ' ):
75
+ if line .startswith (" @@ " ):
70
76
if hunk > 0 :
71
77
break
72
78
hunk += 1
73
- elif line .startswith ('-' ):
79
+ elif line .startswith ("-" ):
74
80
if old or new :
75
81
break
76
82
old = line
77
- elif line .startswith ('+' ):
83
+ elif line .startswith ("+" ):
78
84
if not old or new :
79
85
break
80
86
new = line
81
87
else :
82
- if ' KEYWORDS=' in old and ' KEYWORDS=' in new :
88
+ if " KEYWORDS=" in old and " KEYWORDS=" in new :
83
89
return keyword_line_changes (old , new )
84
90
return None
85
91
86
92
87
- def apply_keyword_changes (ebuild : str , pathname : str ,
88
- changes : KeywordChanges ) -> int :
93
+ def apply_keyword_changes (ebuild : str , pathname : str , changes : KeywordChanges ) -> int :
89
94
result : int = 0
90
95
91
96
with tempfile .TemporaryDirectory () as tmpdir :
@@ -98,8 +103,8 @@ def apply_keyword_changes(ebuild: str, pathname: str,
98
103
if removals :
99
104
for rem in removals :
100
105
# Drop leading '~' and '-' characters and prepend '^'
101
- i = 1 if rem [0 ] in ('~' , '-' ) else 0
102
- args .append ('^' + rem [i :])
106
+ i = 1 if rem [0 ] in ("~" , "-" ) else 0
107
+ args .append ("^" + rem [i :])
103
108
if additions :
104
109
args .extend (additions )
105
110
args .append (ebuild_symlink )
@@ -138,7 +143,20 @@ def main(argv: Sequence[str]) -> int:
138
143
return 0
139
144
140
145
try :
141
- os .execlp ("git" , "git" , "merge-file" , "-L" , "HEAD" , "-L" , "base" , "-L" , "ours" , A , O , B )
146
+ os .execlp (
147
+ "git" ,
148
+ "git" ,
149
+ "merge-file" ,
150
+ "-L" ,
151
+ "HEAD" ,
152
+ "-L" ,
153
+ "base" ,
154
+ "-L" ,
155
+ "ours" ,
156
+ A ,
157
+ O ,
158
+ B ,
159
+ )
142
160
except OSError :
143
161
return - 1
144
162
0 commit comments