<commit_before># Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from slave import recipe_api

class GeneratorScriptApi(recipe_api.RecipeApi):
  def __call__(self, path_to_script, *args, **kwargs):
    """Run a script and generate the steps emitted by that script.

    If a step has a key 'outputs_presentation_json' whose value is
    True, its command is extended with a --presentation-json argument
    pointing to a file where it is expected to write presentation json
    which is used to update that step's presentation on the waterfall.

    Presentation keys are:
      logs: A map of log names to log text.
      links: A map of link text to URIs.
      perf_logs: A map of log names to text.
      step_summary_text: A string to set as the step summary.
      step_text: A string to set as the step text.
      properties: A map of build_property names to JSON-encoded values.

    kwargs:
      env - The environment for the generated steps.
    """
    def update_presentation(step_result):
      p = step_result.presentation
      j = step_result.json.output

      p.logs.update(j.get('logs', {}))
      p.links.update(j.get('links', {}))
      p.perf_logs.update(j.get('perf_logs', {}))
      p.step_summary_text = j.get('step_summary_text', '')
      p.step_text = j.get('step_text', '')
      p.properties.update(j.get('properties', {}))
<commit_msg>Fixing error in generator script module when json.output is None<commit_after># Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from slave import recipe_api

class GeneratorScriptApi(recipe_api.RecipeApi):
  def __call__(self, path_to_script, *args, **kwargs):
    """Run a script and generate the steps emitted by that script.

    If a step has a key 'outputs_presentation_json' whose value is
    True, its command is extended with a --presentation-json argument
    pointing to a file where it is expected to write presentation json
    which is used to update that step's presentation on the waterfall.

    Presentation keys are:
      logs: A map of log names to log text.
      links: A map of link text to URIs.
      perf_logs: A map of log names to text.
      step_summary_text: A string to set as the step summary.
      step_text: A string to set as the step text.
      properties: A map of build_property names to JSON-encoded values.

    kwargs:
      env - The environment for the generated steps.
    """
    def update_presentation(step_result):
      p = step_result.presentation
      j = step_result.json.output

      if j:
        p.logs.update(j.get('logs', {}))
        p.links.update(j.get('links', {}))
        p.perf_logs.update(j.get('perf_logs', {}))
        p.step_summary_text = j.get('step_summary_text', '')
        p.step_text = j.get('step_text', '')
        p.properties.update(j.get('properties', {}))

{'fraction_non_alphanumeric': 0.08692788936450445, 'fraction_numerical': 0.0026341784655910436, 'mean_word_length': 3.099865047233468, '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': '5320360', 'n_tokens_mistral': 892, 'n_tokens_neox': 861, 'n_words': 349}