Skip to content

Commit ff8093a

Browse files
committed
Updating the setup files
1 parent d76f3b9 commit ff8093a

30 files changed

+430
-173
lines changed

code_manager/commands/command.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ class CommandCommand(ConfigurationAware):
1313
name = 'command'
1414

1515
def __init__(self):
16-
self.color = False if self.opt.get('Commands', 'command-colors', fallback=True) == 'false' else True
16+
self.color = False if self.opt.get(
17+
'Commands', 'command-colors', fallback=True,
18+
) == 'false' else True
1719

1820
def execute(self, args, path):
1921

@@ -27,13 +29,22 @@ def execute(self, args, path):
2729

2830
command = args.rest
2931
logging.debug('Running command: [%s] in %s', ' '.join(command), path)
30-
ret = subprocess.run(command, stdout=subprocess.PIPE, cwd=path, check=False)
32+
ret = subprocess.run(
33+
command, stdout=subprocess.PIPE, cwd=path, check=False,
34+
)
3135

3236
for line in ret.stdout.splitlines():
3337
if color:
34-
sys.stdout.buffer.write(bytes(RED + self.pack + RESET + ':', 'utf-8') + line + b'\n')
38+
sys.stdout.buffer.write(
39+
bytes(
40+
RED + self.pack + RESET
41+
+ ':', 'utf-8',
42+
) + line + b'\n',
43+
)
3544
else:
36-
sys.stdout.buffer.write(bytes(self.pack + ':', 'utf-8') + line + b'\n')
45+
sys.stdout.buffer.write(
46+
bytes(self.pack + ':', 'utf-8') + line + b'\n',
47+
)
3748
sys.stdout.buffer.flush()
3849

3950
return 0

code_manager/commands/commit.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ class CommitCommand(ConfigurationAware):
1313
name = 'commit'
1414

1515
def __init__(self):
16-
self.color = False if self.opt.get('Commands', 'commit-colors', fallback=True) == 'false' else True
16+
self.color = False if self.opt.get(
17+
'Commands', 'commit-colors', fallback=True,
18+
) == 'false' else True
1719

1820
def execute(self, args, path):
1921
if not os.path.exists(os.path.join(path, '.git')):
@@ -31,14 +33,24 @@ def execute(self, args, path):
3133
push_command = ['git', 'commit', '-m', msg]
3234
push_command.extend(args.rest)
3335

34-
logging.debug('Running command: [%s] in %s', ' '.join(push_command), path)
36+
logging.debug(
37+
'Running command: [%s] in %s',
38+
' '.join(push_command), path,
39+
)
3540
ret = subprocess.run(push_command, stdout=subprocess.PIPE, cwd=path)
3641

3742
for line in ret.stdout.splitlines():
3843
if color:
39-
sys.stdout.buffer.write(bytes(RED + self.pack + RESET + ':', 'utf-8') + line + b'\n')
44+
sys.stdout.buffer.write(
45+
bytes(
46+
RED + self.pack + RESET
47+
+ ':', 'utf-8',
48+
) + line + b'\n',
49+
)
4050
else:
41-
sys.stdout.buffer.write(bytes(self.pack + ':', 'utf-8') + line + b'\n')
51+
sys.stdout.buffer.write(
52+
bytes(self.pack + ':', 'utf-8') + line + b'\n',
53+
)
4254
sys.stdout.buffer.flush()
4355

4456
return 0

code_manager/commands/find.py

+24-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class FindCommand():
1212
name = 'find'
1313

1414
def __init__(self):
15-
self.color = False if self.opt.get('Commands', 'sed-colors', fallback=True) == 'false' else True
15+
self.color = False if self.opt.get(
16+
'Commands', 'sed-colors', fallback=True,
17+
) == 'false' else True
1618

1719
def execute(self, args, path):
1820

@@ -23,20 +25,35 @@ def execute(self, args, path):
2325

2426
if not os.path.exists(os.path.join(path, '.git')):
2527
find_command = ['find', '-name', args.files]
26-
logging.debug('Running command: [%s] in %s', ' '.join(find_command), path)
27-
ret = subprocess.run(find_command, stdout=subprocess.PIPE, cwd=path, check=False)
28+
logging.debug(
29+
'Running command: [%s] in %s', ' '.join(find_command), path,
30+
)
31+
ret = subprocess.run(
32+
find_command, stdout=subprocess.PIPE, cwd=path, check=False,
33+
)
2834
else:
2935
git_command = ['git', 'ls-files', args.files]
30-
logging.debug('Running command: [%s] in %s', ' '.join(git_command), path)
31-
ret = subprocess.run(git_command, stdout=subprocess.PIPE, cwd=path, check=False)
36+
logging.debug(
37+
'Running command: [%s] in %s', ' '.join(git_command), path,
38+
)
39+
ret = subprocess.run(
40+
git_command, stdout=subprocess.PIPE, cwd=path, check=False,
41+
)
3242

3343
files = ret.stdout.splitlines()
3444

3545
for file_name in files:
3646
if color:
37-
sys.stdout.buffer.write(bytes(RED + self.pack + RESET + ':', 'utf-8') + file_name + b'\n')
47+
sys.stdout.buffer.write(
48+
bytes(
49+
RED + self.pack + RESET + ':',
50+
'utf-8',
51+
) + file_name + b'\n',
52+
)
3853
else:
39-
sys.stdout.buffer.write(bytes(self.pack + ':', 'utf-8') + file_name + b'\n')
54+
sys.stdout.buffer.write(
55+
bytes(self.pack + ':', 'utf-8') + file_name + b'\n',
56+
)
4057

4158
sys.stdout.buffer.flush()
4259

code_manager/commands/grep.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class GrepCommand(ConfigurationAware):
1212
name = 'grep'
1313

1414
def __init__(self):
15-
self.color = False if self.opt.get('Commands', 'grep-colors', fallback=True) == 'false' else True
15+
self.color = False if self.opt.get(
16+
'Commands', 'grep-colors', fallback=True,
17+
) == 'false' else True
1618

1719
def execute(self, args, path):
1820
grep_command = ['grep', '-r']
@@ -26,14 +28,26 @@ def execute(self, args, path):
2628

2729
grep_command.extend(args.rest)
2830

29-
logging.debug('Running command: [%s] in %s', ' '.join(grep_command), path)
30-
ret = subprocess.run(grep_command, stdout=subprocess.PIPE, cwd=path, check=False)
31+
logging.debug(
32+
'Running command: [%s] in %s',
33+
' '.join(grep_command), path,
34+
)
35+
ret = subprocess.run(
36+
grep_command, stdout=subprocess.PIPE, cwd=path, check=False,
37+
)
3138

3239
for line in ret.stdout.splitlines():
3340
if color:
34-
sys.stdout.buffer.write(bytes(RED + self.pack + RESET + ':', 'utf-8') + line + b'\n')
41+
sys.stdout.buffer.write(
42+
bytes(
43+
RED + self.pack + RESET
44+
+ ':', 'utf-8',
45+
) + line + b'\n',
46+
)
3547
else:
36-
sys.stdout.buffer.write(bytes(self.pack + ':', 'utf-8') + line + b'\n')
48+
sys.stdout.buffer.write(
49+
bytes(self.pack + ':', 'utf-8') + line + b'\n',
50+
)
3751
sys.stdout.buffer.flush()
3852

3953
return 0

code_manager/commands/pull.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ class PullCommand(ConfigurationAware):
1313
name = 'pull'
1414

1515
def __init__(self):
16-
self.color = False if self.opt.get('Commands', 'pull-colors', fallback=True) == 'false' else True
16+
self.color = False if self.opt.get(
17+
'Commands', 'pull-colors', fallback=True,
18+
) == 'false' else True
1719

1820
def execute(self, args, path):
1921
if not os.path.exists(os.path.join(path, '.git')):
@@ -25,14 +27,24 @@ def execute(self, args, path):
2527
color = False
2628

2729
pull_command = ['git', 'pull', *args.rest]
28-
logging.debug('Running command: [%s] in %s', ' '.join(pull_command), path)
30+
logging.debug(
31+
'Running command: [%s] in %s',
32+
' '.join(pull_command), path,
33+
)
2934
ret = subprocess.run(pull_command, stdout=subprocess.PIPE, cwd=path)
3035

3136
for line in ret.stdout.splitlines():
3237
if color:
33-
sys.stdout.buffer.write(bytes(RED + self.pack + RESET + ':', 'utf-8') + line + b'\n')
38+
sys.stdout.buffer.write(
39+
bytes(
40+
RED + self.pack + RESET
41+
+ ':', 'utf-8',
42+
) + line + b'\n',
43+
)
3444
else:
35-
sys.stdout.buffer.write(bytes(self.pack + ':', 'utf-8') + line + b'\n')
45+
sys.stdout.buffer.write(
46+
bytes(self.pack + ':', 'utf-8') + line + b'\n',
47+
)
3648
sys.stdout.buffer.flush()
3749

3850
return 0

code_manager/commands/push.py

+28-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ class PushCommand(ConfigurationAware):
1313
name = 'push'
1414

1515
def __init__(self):
16-
self.color = False if self.opt.get('Commands', 'push-colors', fallback=True) == 'false' else True
16+
self.color = False if self.opt.get(
17+
'Commands', 'push-colors', fallback=True,
18+
) == 'false' else True
1719

1820
def execute(self, args, path):
1921
if not os.path.exists(os.path.join(path, '.git')):
@@ -25,21 +27,40 @@ def execute(self, args, path):
2527
color = False
2628

2729
push_command = ['git', 'push', *args.rest]
28-
logging.debug('Running command: [%s] in %s', ' '.join(push_command), path)
29-
ret = subprocess.run(push_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=path)
30+
logging.debug(
31+
'Running command: [%s] in %s',
32+
' '.join(push_command), path,
33+
)
34+
ret = subprocess.run(
35+
push_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=path,
36+
)
3037

3138
for line in ret.stdout.splitlines():
3239
if color:
33-
sys.stdout.buffer.write(bytes(RED + self.pack + RESET + ':', 'utf-8') + line + b'\n')
40+
sys.stdout.buffer.write(
41+
bytes(
42+
RED + self.pack + RESET
43+
+ ':', 'utf-8',
44+
) + line + b'\n',
45+
)
3446
else:
35-
sys.stdout.buffer.write(bytes(self.pack + ':', 'utf-8') + line + b'\n')
47+
sys.stdout.buffer.write(
48+
bytes(self.pack + ':', 'utf-8') + line + b'\n',
49+
)
3650
sys.stdout.buffer.flush()
3751

3852
for line in ret.stderr.splitlines():
3953
if color:
40-
sys.stderr.buffer.write(bytes(RED + self.pack + RESET + ':', 'utf-8') + line + b'\n')
54+
sys.stderr.buffer.write(
55+
bytes(
56+
RED + self.pack + RESET
57+
+ ':', 'utf-8',
58+
) + line + b'\n',
59+
)
4160
else:
42-
sys.stderr.buffer.write(bytes(self.pack + ':', 'utf-8') + line + b'\n')
61+
sys.stderr.buffer.write(
62+
bytes(self.pack + ':', 'utf-8') + line + b'\n',
63+
)
4364
sys.stderr.buffer.flush()
4465

4566
return 0

code_manager/commands/root.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ class RootCommand(ConfigurationAware):
1010
name = 'root'
1111

1212
def __init__(self):
13-
self.color = False if self.opt.get('Commands', 'root-colors', fallback=True) == 'false' else True
13+
self.color = False if self.opt.get(
14+
'Commands', 'root-colors', fallback=True,
15+
) == 'false' else True
1416

1517
def execute(self, args, path):
1618

@@ -21,9 +23,13 @@ def execute(self, args, path):
2123

2224
line = bytes(path, 'utf-8')
2325
if color:
24-
sys.stdout.buffer.write(bytes(RED + self.pack + RESET + ':', 'utf-8') + line + b'\n')
26+
sys.stdout.buffer.write(
27+
bytes(RED + self.pack + RESET + ':', 'utf-8') + line + b'\n',
28+
)
2529
else:
26-
sys.stdout.buffer.write(bytes(self.pack + ':', 'utf-8') + line + b'\n')
30+
sys.stdout.buffer.write(
31+
bytes(self.pack + ':', 'utf-8') + line + b'\n',
32+
)
2733

2834
sys.stdout.buffer.flush()
2935

code_manager/commands/sed.py

+32-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class SedCommand(ConfigurationAware):
1414
name = 'sed'
1515

1616
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
1820

1921
def execute(self, args, path):
2022

@@ -25,12 +27,20 @@ def execute(self, args, path):
2527

2628
if not os.path.exists(os.path.join(path, '.git')):
2729
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+
)
3036
else:
3137
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+
)
3444

3545
files = ret.stdout.splitlines()
3646

@@ -42,14 +52,27 @@ def execute(self, args, path):
4252
sed_command.extend(args.sed_args)
4353
sed_command.extend(['-e', args.expression, file_name])
4454

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+
)
4761

4862
for line in ret.stdout.splitlines():
4963
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+
)
5169
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+
)
5376
sys.stdout.buffer.flush()
5477

5578
return 0

code_manager/core/cache_container.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ def save_cache(self):
6868
continue
6969

7070
json.dump(
71-
p, open(os.path.join(self.code_dir, p['root'], '.code_manager_cache'), 'w'),
71+
p, open(
72+
os.path.join(
73+
self.code_dir,
74+
p['root'], '.code_manager_cache',
75+
), 'w',
76+
),
7277
indent=4, separators=(',', ' : '),
7378
)
7479

0 commit comments

Comments
 (0)