<commit_before>#!/usr/bin/python

# Copyright (C) 2010-2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""Display and display workers module for gae-last-across-the-finish-line."""


__author__ = '<EMAIL> (<NAME>)'


# General libraries
import json
import random

# App engine specific libraries
from google.appengine.api import channel


HEX_DIGITS = '0123456789ABCDEF'


def GenerateTable(table_id, rows, columns):
  """Generates an HTML table with a fixed number of rows and columns.

  Args:
    table_id: An HTML ID for the table created
    rows: The number of rows in the table
    columns: The number of columns in the table
  """
  table_elts = ['<table id="{}">'.format(table_id), '<tbody>']
  for row in range(rows):
    row_add = ['<tr>']
    for column in range(columns):
      index = columns*row + column
      row_add.append('<td id="square{}" />'.format(index))
    row_add.append('</tr>')
    table_elts.extend(row_add)
  table_elts.extend(['</tbody>', '</table>'])
  return '\n'.join(table_elts)


def RandomRowColumnOrdering(rows, columns):
  """Generates a random ordering of all row, column pairs.

  Uses random.shuffle to shuffle the integers between 0 and
  rows*columns - 1 (inclusive) and then maps each of these
  integers to a corresponding row, column pair.

  Args:
    rows: The number of rows in the table
    columns: The number of columns in the table
  """
  square_indices = range(rows*columns)
  random.shuffle(square_indices)
  return [divmod(index, columns) for index in square_indices]


def RandHexColor(length=6):
  """Generates a random color using hexadecimal digits.

  Args:<commit_msg>Changing to template in GenerateTable.<commit_after>#!/usr/bin/python

# Copyright (C) 2010-2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""Display and display workers module for gae-last-across-the-finish-line."""


__author__ = '<EMAIL> (<NAME>)'


# General libraries
import json
import random

# App engine specific libraries
from google.appengine.api import channel
from jinja2 import Template


HEX_DIGITS = '0123456789ABCDEF'
TABLE_TEMPLATE = Template("""\
<table id="{{ table_id }}">
  <tbody>
    {% for row in rows %}
    <tr>
      {% for column in columns %}
      <td id="square{{ columns|length * row + column }}" />
      {% endfor %}
    </tr>
    {% endfor %}
  </tbody>
</table>""")


def GenerateTable(table_id, num_rows, num_columns):
  """Generates an HTML table with a fixed number of rows and columns.

  Args:
    table_id: An HTML ID for the table created
    num_rows: The number of rows in the table
    num_columns: The number of columns in the table
  """
  return TABLE_TEMPLATE.render(table_id=table_id,
                               rows=range(num_rows),
                               columns=range(num_columns))


def RandomRowColumnOrdering(rows, columns):
  """Generates a random ordering of all row, column pairs.

  Uses random.shuffle to shuffle the integers between 0 and
  rows*columns - 1 (inclusive) and then maps each of these
  integers to a corresponding row, column pair.

  Args:
    rows: The number of rows in the table
    columns: The number of columns in the table
  """
  square_indices = range(rows*columns)
  random.shuffle(square_indices)
  return [divmod(index, columns) for index in square_indices]


def RandHexColor(length=6):
  """Generates a random color using hexadecimal digits.

  Args:
{'fraction_non_alphanumeric': 0.09740112994350282, 'fraction_numerical': 0.01152542372881356, 'mean_word_length': 3.713525026624068, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7673383', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1261, 'n_words': 512}