-
Notifications
You must be signed in to change notification settings - Fork 77
/
update_header.py
33 lines (30 loc) · 1.36 KB
/
update_header.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding:utf-8 -*-
import re
import sys,os
def updateHeader(DIR, PROJ):
for path in os.listdir(DIR):
fullPath = os.path.join(DIR, path)
if os.path.isdir(fullPath):
if path != "Pods":
updateHeader(fullPath, PROJ)
elif os.path.isfile(fullPath):
if path.lower().endswith('.m') or path.lower().endswith('.h'):
print('Updating: %s' % (path))
codeFile = open(fullPath, 'r+')
content = codeFile.read()
content = re.sub('^(//[^\n]*\n)+//(?P<smile>[^\n]*)\n',
'//\n' +
'// ' + path + '\n' +
'// ' + PROJ + '\n' +
'//\n' +
'// Copyright (c) 2017-2018 Alibaba. All rights reserved.\n' +
'//' + '\g<smile>' + '\n',
content)
codeFile.seek(0)
codeFile.write(content)
codeFile.truncate()
codeFile.close()
updateHeader(os.path.join(sys.path[0], 'VirtualView'), 'VirtualView')
updateHeader(os.path.join(sys.path[0], 'VirtualViewDemo'), 'VirtualViewDemo')
updateHeader(os.path.join(sys.path[0], 'VirtualViewTest'), 'VirtualViewTest')
print('Header updating is done.')