mirror of
https://github.com/vinta/awesome-python.git
synced 2024-11-28 06:21:08 +00:00
Merge branch 'master' of https://github.com/vinta/awesome-python
This commit is contained in:
commit
720275c332
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -1,6 +1,10 @@
|
||||||
## Why this framework/library/software/resource is awesome?
|
## What is this Python project?
|
||||||
|
|
||||||
A few sentences describing the reason.
|
Describe features.
|
||||||
|
|
||||||
|
## What's the difference between this Python project and similar ones?
|
||||||
|
|
||||||
|
Enumerate comparisons.
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
30
sort.py
30
sort.py
|
@ -13,6 +13,33 @@
|
||||||
and flattening the end structure into a list of lines. Revision 2 maybe ^.^.
|
and flattening the end structure into a list of lines. Revision 2 maybe ^.^.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def sort_blocks():
|
||||||
|
# First, we load the current README into memory
|
||||||
|
with open('README.md', 'r') as read_me_file:
|
||||||
|
read_me = read_me_file.read()
|
||||||
|
|
||||||
|
# Separating the 'table of contents' from the contents (blocks)
|
||||||
|
table_of_contents = ''.join(read_me.split('- - -')[0])
|
||||||
|
blocks = ''.join(read_me.split('- - -')[1]).split('\n# ')
|
||||||
|
for i in range(len(blocks)):
|
||||||
|
if i == 0:
|
||||||
|
blocks[i] = blocks[i] + '\n'
|
||||||
|
else:
|
||||||
|
blocks[i] = '# ' + blocks[i] + '\n'
|
||||||
|
|
||||||
|
# Sorting the libraries
|
||||||
|
inner_blocks = sorted(blocks[0].split('##'))
|
||||||
|
for i in range(1 , len(inner_blocks)):
|
||||||
|
if inner_blocks[i][0] != '#':
|
||||||
|
inner_blocks[i] = '##' + inner_blocks[i]
|
||||||
|
inner_blocks=''.join(inner_blocks)
|
||||||
|
|
||||||
|
# Replacing the non-sorted libraries by the sorted ones and gathering all at the final_README file
|
||||||
|
blocks[0] = inner_blocks
|
||||||
|
final_README = table_of_contents + '- - -' + ''.join(blocks)
|
||||||
|
|
||||||
|
with open('README.md', 'w+') as sorted_file:
|
||||||
|
sorted_file.write(final_README)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# First, we load the current README into memory as an array of lines
|
# First, we load the current README into memory as an array of lines
|
||||||
|
@ -45,6 +72,9 @@ def main():
|
||||||
# And the result is written back to README.md
|
# And the result is written back to README.md
|
||||||
sorted_file.write(''.join(blocks))
|
sorted_file.write(''.join(blocks))
|
||||||
|
|
||||||
|
# Then we call the sorting method
|
||||||
|
sort_blocks()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user