<commit_before><?php

// Check for console
$input = new \Symfony\Component\Console\Input\ArgvInput();
$is_auth_command = $input->getFirstArgument() == 'hubdrop:github_auth';

// @TODO: Breaks all commands! Should only run on hubdrop commands.

// Check for server variables
$server_vars_exist = isset($_SERVER['SYMFONY__HUBDROP__GITHUB_AUTHORIZATION_KEY']);

// If the expected SERVER variables are not set AND we are not asking for
// github authorization, look for attributes.json
if (!$server_vars_exist){

  // Look for an attributes.json file. First hit wins.
  $path_suggestions = array();
  $path_suggestions[] = '/vagrant/attributes.json';
  $path_suggestions[] = '/var/hubdrop/app/attributes.json';
  // @TODO: add the users home directory.

  foreach ($path_suggestions as $path){
    if (file_exists($path)){
      $attributes = json_decode(file_get_contents($path));
      break;
    }
  }

  // Load JSON attributes
  // Bail out if it doesn't parse.
  if (!is_object($attributes)){
    throw new \Exception('Cannot find hubdrop $_SERVER variables or attributes.json file.');
  }

  // If missing authorization key...
  if (!$is_auth_command && empty($attributes->hubdrop->github->authorization_key)){
    throw new \Exception('Missing github authorization key.  Run `hubdrop:github_auth yourgithubusername` to get a key, then add to your attributes.json file.');
  }

  // Set our required parameters.
  $container->setParameter('hubdrop.github_username', $attributes->hubdrop->github->username);
  $container->setParameter('hubdrop.github_organization', $attributes->hubdrop->github->organization);
  $container->setParameter('hubdrop.github_authorization_key', $attributes->hubdrop->github->authorization_key);

  $container->setParameter('hubdrop.drupal_username', $attributes->hubdrop->drupal->username);

  $container->setParameter('hubdrop.url', $attributes->hubdrop->url);
}<commit_msg>Can't get this to work on prod<commit_after><?php
//
//// Check for console
//$input = new \Symfony\Component\Console\Input\ArgvInput();
//$is_auth_command = $input->getFirstArgument() == 'hubdrop:github_auth';
//
//// @TODO: Breaks all commands! Should only run on hubdrop commands.
//
//// Check for server variables
//$server_vars_exist = isset($_SERVER['SYMFONY__HUBDROP__GITHUB_AUTHORIZATION_KEY']);
//
//// If the expected SERVER variables are not set AND we are not asking for
//// github authorization, look for attributes.json
//if (!$server_vars_exist){
//
//  // Look for an attributes.json file. First hit wins.
//  $path_suggestions = array();
//  $path_suggestions[] = '/vagrant/attributes.json';
//  $path_suggestions[] = '/var/hubdrop/app/attributes.json';
//  // @TODO: add the users home directory.
//
//  foreach ($path_suggestions as $path){
//    if (file_exists($path)){
//      $attributes = json_decode(file_get_contents($path));
//      break;
//    }
//  }
//
//  // Load JSON attributes
//  // Bail out if it doesn't parse.
//  if (!is_object($attributes)){
//    throw new \Exception('Cannot find hubdrop $_SERVER variables or attributes.json file.');
//  }
//
//  // If missing authorization key...
//  if (!$is_auth_command && empty($attributes->hubdrop->github->authorization_key)){
//    throw new \Exception('Missing github authorization key.  Run `hubdrop:github_auth yourgithubusername` to get a key, then add to your attributes.json file.');
//  }
//
//  // Set our required parameters.
//  $container->setParameter('hubdrop.github_username', $attributes->hubdrop->github->username);
//  $container->setParameter('hubdrop.github_organization', $attributes->hubdrop->github->organization);
//  $container->setParameter('hubdrop.github_authorization_key', $attributes->hubdrop->github->authorization_key);
//
//  $container->setParameter('hubdrop.drupal_username', $attributes->hubdrop->drupal->username);
//
//  $container->setParameter('hubdrop.url', $attributes->hubdrop->url);
//}
{'fraction_non_alphanumeric': 0.15821656050955413, 'fraction_numerical': 0.0, 'mean_word_length': 4.269798657718121, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '469694', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1157, 'n_words': 280}