check_copyright_header.py 842 B

1234567891011121314151617181920
  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. if __name__ == "__main__":
  10. for ext in ["*.py", "*.sh"]:
  11. for file in WORK_DIR.rglob(ext):
  12. text = file.read_text()
  13. if not re.search(PATTERN, text):
  14. text = HEADER + text
  15. file.write_text(text)