mirror of
https://github.com/wassname/vllm.git
synced 2026-06-27 17:32:55 +08:00
[Misc] Fix improper placement of SPDX header in scripts (#12694)
Signed-off-by: Russell Bryant <rbryant@redhat.com>
This commit is contained in:
@@ -10,18 +10,25 @@ def check_spdx_header(file_path):
|
||||
with open(file_path, encoding='UTF-8') as file:
|
||||
lines = file.readlines()
|
||||
if not lines:
|
||||
# not necessary for an empty file like __init__.py
|
||||
# Empty file like __init__.py
|
||||
return True
|
||||
if not lines[0].strip().startswith(SPDX_HEADER_PREFIX):
|
||||
return False
|
||||
return True
|
||||
for line in lines:
|
||||
if line.strip().startswith(SPDX_HEADER_PREFIX):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def add_header(file_path):
|
||||
with open(file_path, 'r+', encoding='UTF-8') as file:
|
||||
lines = file.readlines()
|
||||
file.seek(0, 0)
|
||||
file.write(SPDX_HEADER + '\n\n' + ''.join(lines))
|
||||
if lines and lines[0].startswith("#!"):
|
||||
file.write(lines[0])
|
||||
file.write(SPDX_HEADER + '\n')
|
||||
file.writelines(lines[1:])
|
||||
else:
|
||||
file.write(SPDX_HEADER + '\n')
|
||||
file.writelines(lines)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
Reference in New Issue
Block a user