Created
July 28, 2018 19:44
-
-
Save RayTwitty/01bf6b2012d8b39cb4b731a5de19701c to your computer and use it in GitHub Desktop.
Форматирует историю изменений в более читаемый вид.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, re | |
cur_dir = os.path.dirname(os.path.abspath(__file__)) | |
file = open(cur_dir + '\log.txt') | |
buff = [] | |
ignored_lines = [ | |
'Author: .*', | |
'Date: .*', | |
'Message:', | |
'----', | |
'Modified : .*', | |
'Added : .*', | |
'Removed : .*' | |
] | |
def checkLine(line): | |
for pattern in ignored_lines: | |
if re.search(pattern, line): | |
return False | |
return True | |
sep = False | |
for line in file: | |
if re.search('Revision: \d+', line): | |
if sep: | |
buff.append('------------------------------------------\n\n') | |
buff.append('[%s]\n\n' % re.search('\d+', line).group(0)) | |
sep = True | |
elif checkLine(line): | |
buff.append(line) | |
file = open(cur_dir + '\log_formatted.txt', 'w') | |
for line in buff: | |
file.write(line) | |
file.close() | |
print('Done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment