@@ -14,7 +14,9 @@ class SedCommand(ConfigurationAware):
14
14
name = 'sed'
15
15
16
16
def __init__ (self ):
17
- self .color = False if self .opt .get ('Commands' , 'sed-colors' , fallback = True ) == 'false' else True
17
+ self .color = False if self .opt .get (
18
+ 'Commands' , 'sed-colors' , fallback = True ,
19
+ ) == 'false' else True
18
20
19
21
def execute (self , args , path ):
20
22
@@ -25,12 +27,20 @@ def execute(self, args, path):
25
27
26
28
if not os .path .exists (os .path .join (path , '.git' )):
27
29
find_command = ['find' , '-name' , args .files ]
28
- logging .debug ('Running command: [%s] in %s' , ' ' .join (find_command ), path )
29
- ret = subprocess .run (find_command , stdout = subprocess .PIPE , cwd = path , check = False )
30
+ logging .debug (
31
+ 'Running command: [%s] in %s' , ' ' .join (find_command ), path ,
32
+ )
33
+ ret = subprocess .run (
34
+ find_command , stdout = subprocess .PIPE , cwd = path , check = False ,
35
+ )
30
36
else :
31
37
git_command = ['git' , 'ls-files' , args .files ]
32
- logging .debug ('Running command: [%s] in %s' , ' ' .join (git_command ), path )
33
- ret = subprocess .run (git_command , stdout = subprocess .PIPE , cwd = path , check = False )
38
+ logging .debug (
39
+ 'Running command: [%s] in %s' , ' ' .join (git_command ), path ,
40
+ )
41
+ ret = subprocess .run (
42
+ git_command , stdout = subprocess .PIPE , cwd = path , check = False ,
43
+ )
34
44
35
45
files = ret .stdout .splitlines ()
36
46
@@ -42,14 +52,27 @@ def execute(self, args, path):
42
52
sed_command .extend (args .sed_args )
43
53
sed_command .extend (['-e' , args .expression , file_name ])
44
54
45
- logging .debug ('Running command: [%s] in ' , ' ' .join (sed_command ), path )
46
- ret = subprocess .run (sed_command , stdout = subprocess .PIPE , cwd = path , check = False )
55
+ logging .debug (
56
+ 'Running command: [%s] in ' , ' ' .join (sed_command ), path ,
57
+ )
58
+ ret = subprocess .run (
59
+ sed_command , stdout = subprocess .PIPE , cwd = path , check = False ,
60
+ )
47
61
48
62
for line in ret .stdout .splitlines ():
49
63
if color :
50
- sys .stdout .buffer .write (bytes (RED + self .pack + RESET + ':' + CYAN + file_name + RESET + ':' , 'utf-8' ) + line + b'\n ' )
64
+ sys .stdout .buffer .write (
65
+ bytes (
66
+ RED + self .pack + RESET + ':' + CYAN + file_name + RESET + ':' , 'utf-8' ,
67
+ ) + line + b'\n ' ,
68
+ )
51
69
else :
52
- sys .stdout .buffer .write (bytes (self .pack + ':' + file_name + ':' , 'utf-8' ) + line + b'\n ' )
70
+ sys .stdout .buffer .write (
71
+ bytes (
72
+ self .pack + ':' + file_name
73
+ + ':' , 'utf-8' ,
74
+ ) + line + b'\n ' ,
75
+ )
53
76
sys .stdout .buffer .flush ()
54
77
55
78
return 0
0 commit comments