Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f83a33

Browse files
author
Sourcery AI
committed
'Refactored by Sourcery'
1 parent e0594e3 commit 7f83a33

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

sort.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,17 @@ def sort_blocks():
2323
table_of_contents = ''.join(read_me.split('- - -')[0])
2424
blocks = ''.join(read_me.split('- - -')[1]).split('\n# ')
2525
for i in range(len(blocks)):
26-
if i == 0:
27-
blocks[i] = blocks[i] + '\n'
28-
else:
29-
blocks[i] = '# ' + blocks[i] + '\n'
30-
26+
blocks[i] = blocks[i] + '\n' if i == 0 else f'# {blocks[i]}' + '\n'
3127
# Sorting the libraries
3228
inner_blocks = sorted(blocks[0].split('##'))
3329
for i in range(1, len(inner_blocks)):
3430
if inner_blocks[i][0] != '#':
35-
inner_blocks[i] = '##' + inner_blocks[i]
31+
inner_blocks[i] = f'##{inner_blocks[i]}'
3632
inner_blocks = ''.join(inner_blocks)
3733

3834
# Replacing the non-sorted libraries by the sorted ones and gathering all at the final_README file
3935
blocks[0] = inner_blocks
40-
final_README = table_of_contents + '- - -' + ''.join(blocks)
36+
final_README = f'{table_of_contents}- - -' + ''.join(blocks)
4137

4238
with open('README.md', 'w+') as sorted_file:
4339
sorted_file.write(final_README)
@@ -57,7 +53,7 @@ def main():
5753
s_line = line.lstrip()
5854
indent = len(line) - len(s_line)
5955

60-
if any([s_line.startswith(s) for s in ['* [', '- [']]):
56+
if any(s_line.startswith(s) for s in ['* [', '- [']):
6157
if indent == last_indent:
6258
blocks[-1].append(line)
6359
else:

0 commit comments

Comments
 (0)