code: def get_directory_hash(
      directory: Path, skip_path_regexp: str | None = None
  ) -> str:
      files = sorted(directory.rglob("*"))
      if skip_path_regexp:
          matcher = re.compile(skip_path_regexp)
          files = [
              file
              for file in files
              if not matcher.match(os.fspath(file.resolve()))
          ]
      sha = hashlib.sha256()
      for file in files:
          if file.is_file() and not file.name.startswith("."):
              sha.update(file.read_bytes())
      return sha.hexdigest()
  
file_path: airflow/scripts/ci/pre_commit/pre_commit_compile_www_assets.py
imports: from __future__ import annotations
  import hashlib
  import os
  import re
  import shutil
  import subprocess
  import sys
  from pathlib import Path
label_desc: Use image node_id 1 for calling a global function with example usage: get_directory_hash(directory, skip_path_regexp) and returns: sha