import re


def GetCipdPackagePath(pkg_yaml_file):
  """Find CIPD package path in .yaml file.

  There should one line in .yaml file, e.g.:
  "package: chrome_internal/third_party/android_sdk/internal/q/add-ons" or
  "package: chromium/third_party/android_sdk/public/platforms"

  Args:
    pkg_yaml_file: The yaml file to find CIPD package path.

  Returns:
    The CIPD package path in yaml file.
  """
  cipd_package_path = ''
  with open(pkg_yaml_file) as f:
    pattern = re.compile(
        # Match the argument with "package: "
        r'(^\s*package:\s*)'
        # The CIPD package path we want
        r'([\w\/-]+)'
        # End of string
        r'(\s*?$)')
    for line in f:
      found = re.match(pattern, line)
      if found:
        cipd_package_path = found.group(2)
        break
  return cipd_package_path