Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
add checking for md files and expand 3rdparty to individual folders
Browse files Browse the repository at this point in the history
  • Loading branch information
ciyongch committed Jun 11, 2020
1 parent 7ae5f4b commit 81e8ec8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tools/license_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@
'docker/Dockerfiles',

# Git submodules under different licenses
'3rdparty',
'3rdparty/ctc_include/contrib/moderngpu',
'3rdparty/dlpack',
'3rdparty/dmlc-core',
'3rdparty/googletest',
'3rdparty/mkldnn',
'3rdparty/nvidia_cub',
'3rdparty/onnx-tensorrt',
'3rdparty/openmp',
'3rdparty/ps-lite',
'3rdparty/tvm',

# 3rdparty headerfiles under different licenses
'include/mkldnn',
Expand Down Expand Up @@ -123,7 +132,8 @@
'.pm':'#', '.scala':'*', '.cc':'*', '.sh':'#', '.cmake':'#',
'.java':'*', '.sh':'#', '.cpp':'*', '.hpp':'*', '.c':'*',
'.bat':'rem', '.pl':'#', '.m':'%', '.R':'#', '.mk':'#', '.cfg':'#',
'.t':'#', '.ps1':'#', '.jl':'#', '.clj':';;', '.pyx':'#', '.js':'*'}
'.t':'#', '.ps1':'#', '.jl':'#', '.clj':';;', '.pyx':'#', '.js':'*',
'.md':'<!---'}

# Previous license header, which will be removed
_OLD_LICENSE = re.compile('.*Copyright.*by Contributors')
Expand Down Expand Up @@ -194,6 +204,8 @@ def _get_license(comment_mark):
body += comment_mark
if len(l):
body += ' ' + l
if comment_mark == '<!---':
body += ' -->'
body += '\n'

if comment_mark == '*':
Expand Down Expand Up @@ -226,7 +238,9 @@ def file_has_license(fname):
def file_add_license(fname):
if not should_have_license(fname):
return
if file_have_valid_license(fname):
with open(fname, 'r', encoding="utf-8") as f:
lines = f.readlines()
if _lines_have_apache_license(lines):
return
_, ext = os.path.splitext(fname)
with open(fname, 'w', encoding="utf-8") as f:
Expand Down

0 comments on commit 81e8ec8

Please sign in to comment.