Skip to content

Instantly share code, notes, and snippets.

@RayTwitty
Created July 28, 2018 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RayTwitty/01bf6b2012d8b39cb4b731a5de19701c to your computer and use it in GitHub Desktop.
Save RayTwitty/01bf6b2012d8b39cb4b731a5de19701c to your computer and use it in GitHub Desktop.
Форматирует историю изменений в более читаемый вид.
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