check_copyright_header.py 1.1 KB

123456789101112131415161718192021222324252627
  1. # Copyright (c) Meta Platforms, Inc. and affiliates.
  2. # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.
  3. import re
  4. from pathlib import Path
  5. WORK_DIR = Path(__file__).parents[1]
  6. PATTERN = "(Meta Platforms, Inc. and affiliates)|(Facebook, Inc(\.|,)? and its affiliates)|([0-9]{4}-present(\.|,)? Facebook)|([0-9]{4}(\.|,)? Facebook)"
  7. HEADER = """# Copyright (c) Meta Platforms, Inc. and affiliates.
  8. # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.\n\n"""
  9. #Files in black list must be relative to main repo folder
  10. BLACKLIST = ["eval/open_llm_leaderboard/hellaswag_utils.py"]
  11. if __name__ == "__main__":
  12. for ext in ["*.py", "*.sh"]:
  13. for file in WORK_DIR.rglob(ext):
  14. normalized = file.relative_to(WORK_DIR)
  15. if normalized.as_posix() in BLACKLIST:
  16. continue
  17. text = file.read_text()
  18. if not re.search(PATTERN, text):
  19. text = HEADER + text
  20. file.write_text(text)