check_copyright_header.py 677 B

1234567891011121314151617
  1. import re
  2. from pathlib import Path
  3. WORK_DIR = Path(__file__).parents[1]
  4. PATTERN = "(Meta Platforms, Inc. and affiliates)|(Facebook, Inc(\.|,)? and its affiliates)|([0-9]{4}-present(\.|,)? Facebook)|([0-9]{4}(\.|,)? Facebook)"
  5. HEADER = """# Copyright (c) Meta Platforms, Inc. and affiliates.
  6. # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.\n\n"""
  7. if __name__ == "__main__":
  8. for ext in ["*.py", "*.sh"]:
  9. for file in WORK_DIR.rglob(ext):
  10. text = file.read_text()
  11. if not re.search(PATTERN, text):
  12. text = HEADER + text
  13. file.write_text(text)