<commit_before>#!/bin/bash
##
##  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
##
##  Use of this source code is governed by a BSD-style license
##  that can be found in the LICENSE file in the root of the source
##  tree. An additional intellectual property rights grant can be found
##  in the file PATENTS.  All contributing project authors may
##  be found in the AUTHORS file in the root of the source tree.
set -e

if [[ $(basename $(pwd)) != "installer" ]] || \
    [[ $(basename $(dirname $(pwd))) != "webmquicktime" ]]; then
  echo "$(basename $0) must be run from webmquicktime/installer"
  exit 1
fi

source scripts/build/util.sh

readonly BUNDLE="$1"
readonly PLIST_BUDDY="/usr/local/bin/PlistBuddy"

read_bundle_info() {
  local readonly NAME="$1"
  local readonly COMMAND="Print :CFBundle${NAME}"
  local readonly PLIST_PATH="${BUNDLE}/Contents/Info.plist"
  file_exists "${PLIST_PATH}" || die "${PLIST_PATH} does not exist."
  ${PLIST_BUDDY} -c "${COMMAND}" "${PLIST_PATH}"
}

read_bundle_id() {
  read_bundle_info Identifier
}

read_bundle_version() {
  read_bundle_info Version
}

file_exists "${PLIST_BUDDY}" || die "${PLIST_BUDDY} does not exist."
file_exists "${BUNDLE}" || die "${BUNDLE} does not exist."

shopt -s nocasematch
if [[ "$2" =~ ^v$|ver|version ]]; then
  read_bundle_version
elif [[ "$2" =~ ^id$|identifier ]]; then
  read_bundle_id<commit_msg>read_bundle_plist.sh: allow read from plist files.<commit_after>#!/bin/bash
##
##  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
##
##  Use of this source code is governed by a BSD-style license
##  that can be found in the LICENSE file in the root of the source
##  tree. An additional intellectual property rights grant can be found
##  in the file PATENTS.  All contributing project authors may
##  be found in the AUTHORS file in the root of the source tree.
set -e

if [[ $(basename $(pwd)) != "installer" ]] || \
    [[ $(basename $(dirname $(pwd))) != "webmquicktime" ]]; then
  echo "$(basename $0) must be run from webmquicktime/installer"
  exit 1
fi

source scripts/build/util.sh

readonly BUNDLE="$1"
readonly PLIST_BUDDY="/usr/local/bin/PlistBuddy"

read_bundle_info() {
  local readonly NAME="$1"
  [[ -n "${NAME}" ]] || die "missing command name in ${FUNCNAME}."
  local readonly COMMAND="Print :CFBundle${NAME}"
  # When |BUNDLE| file name is a plist file, just read from the plist file.
  if [[ "$(basename "${BUNDLE}")" =~ \.plist$ ]]; then
    local readonly PLIST_PATH="${BUNDLE}"
  else
    local readonly PLIST_PATH="${BUNDLE}/Contents/Info.plist"
  fi
  file_exists "${PLIST_PATH}" || die "${PLIST_PATH} does not exist."
  ${PLIST_BUDDY} -c "${COMMAND}" "${PLIST_PATH}"
}

read_bundle_id() {
  read_bundle_info Identifier
}

read_bundle_version() {
  read_bundle_info Version
}

file_exists "${PLIST_BUDDY}" || die "${PLIST_BUDDY} does not exist."
file_exists "${BUNDLE}" || die "${BUNDLE} does not exist."

shopt -s nocasematch
if [[ "$2" =~ ^v$|ver|version ]]; then
  read_bundle_version
elif [[ "$2" =~ ^id$|identifier ]]; then
  read_bundle_id
{'fraction_non_alphanumeric': 0.14697313046293298, 'fraction_numerical': 0.006474587245063127, 'mean_word_length': 4.4787234042553195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2130281', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1047, 'n_words': 338}