-
Notifications
You must be signed in to change notification settings - Fork 274
/
update_header.py
33 lines (31 loc) · 1.43 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
33
# -*- 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) 2015-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], 'LazyScrollView'), 'LazyScrollView')
updateHeader(os.path.join(sys.path[0], 'LazyScrollViewDemo'), 'LazyScrollViewDemo')
updateHeader(os.path.join(sys.path[0], 'LazyScrollViewTest'), 'LazyScrollViewTest')
updateHeader(os.path.join(sys.path[0], 'TMUtils'), 'TMUtils')
print('Header updating is done.')