2017-08-13 14:27:08 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Cleans up `README.md`.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import codecs
|
|
|
|
|
|
|
|
|
|
|
|
def fix_dashes(lines):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
fixed_lines = []
|
|
|
|
|
2017-08-27 11:33:13 +02:00
|
|
|
# Distinguish between the prologue and the content.
|
2017-08-13 14:27:08 +02:00
|
|
|
within_content = False
|
|
|
|
|
2017-08-27 11:33:13 +02:00
|
|
|
# Iterate over the awesome lines.
|
2017-08-13 14:27:08 +02:00
|
|
|
for line in lines:
|
|
|
|
|
2017-08-27 11:33:13 +02:00
|
|
|
# The current line is within the content.
|
2017-08-13 14:27:08 +02:00
|
|
|
if within_content:
|
2017-08-27 11:33:13 +02:00
|
|
|
|
|
|
|
# Adjust the dash.
|
2017-08-13 14:27:08 +02:00
|
|
|
fixed_lines.append(line.replace(u' - ', u' — '))
|
|
|
|
#
|
2017-08-27 11:33:13 +02:00
|
|
|
# The current line is within the prologue.
|
2017-08-13 14:27:08 +02:00
|
|
|
else:
|
2017-08-27 11:33:13 +02:00
|
|
|
# The prologue has ended.
|
2017-08-13 14:27:08 +02:00
|
|
|
if line.startswith(u'## Applications'):
|
|
|
|
within_content = True
|
|
|
|
|
2017-08-27 11:33:13 +02:00
|
|
|
# Leave the current line unmodified.
|
2017-08-13 14:27:08 +02:00
|
|
|
fixed_lines.append(line)
|
|
|
|
|
|
|
|
return fixed_lines
|
|
|
|
|
|
|
|
# end def fix_dashes
|
|
|
|
|
|
|
|
|
|
|
|
# Read the awesome file.
|
|
|
|
with codecs.open('README.md', encoding='utf8') as awesome_file:
|
|
|
|
awesome_lines = awesome_file.readlines()
|
|
|
|
|
2017-08-27 11:33:13 +02:00
|
|
|
# Fix the dashes.
|
2017-08-13 14:27:08 +02:00
|
|
|
awesome_lines = fix_dashes(awesome_lines)
|
|
|
|
|
|
|
|
# Write the awesome file.
|
|
|
|
with codecs.open('README.md', 'wb', encoding='utf8') as awesome_file:
|
|
|
|
awesome_file.writelines(awesome_lines)
|