<commit_before>#!/usr/bin/env python2.5
#
# Copyright 2009 the Melange authors.
#
# 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.

"""A Django template tag library containing GCI Task 
specific Comments helpers.
"""

__authors__ = [
  '"Madhusudan.C.S" <<EMAIL>>',
  ]


from google.appengine.ext import blobstore

from django import template


register = template.Library()


@register.inclusion_tag(
    'modules/gci/templatetags/_as_gci_task_comments.html',
    takes_context=True)
def as_gci_task_comment(context, comment):
  """Returns a HTML representation of a GCI task's comments.
  """

  context['comment'] =  comment
  context['comment_id'] =  comment.key().id_or_name()
  return context


@register.inclusion_tag(
    'modules/gci/templatetags/_as_gci_task_ws.html',
    takes_context=True)
def as_gci_task_ws(context, comment):
  """Returns a HTML representation of a GCI task's work submissions.
  """

  context['ws'] =  comment
  context['ws_id'] = comment.key().id_or_name()

  if comment.upload_of_work:
    blob_key = comment.upload_of_work.key()

    blob = blobstore.BlobInfo.get(blob_key)
    context['ws_file_blob_key'] = blob_key
    context['ws_file_name'] = blob.filename

    suffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
    file_size_int = blob.size

    for s in suffixes:
      file_size_int /= 1024
      if file_size_int < 1024:<commit_msg>Temporary fix to handle the case when the blobkey exists for a ghost blob.<commit_after>#!/usr/bin/env python2.5
#
# Copyright 2009 the Melange authors.
#
# 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.

"""A Django template tag library containing GCI Task 
specific Comments helpers.
"""

__authors__ = [
  '"Madhusudan.C.S" <<EMAIL>>',
  ]


from google.appengine.ext import blobstore

from django import template


register = template.Library()


@register.inclusion_tag(
    'modules/gci/templatetags/_as_gci_task_comments.html',
    takes_context=True)
def as_gci_task_comment(context, comment):
  """Returns a HTML representation of a GCI task's comments.
  """

  context['comment'] =  comment
  context['comment_id'] =  comment.key().id_or_name()
  return context


@register.inclusion_tag(
    'modules/gci/templatetags/_as_gci_task_ws.html',
    takes_context=True)
def as_gci_task_ws(context, comment):
  """Returns a HTML representation of a GCI task's work submissions.
  """

  context['ws'] =  comment
  context['ws_id'] = comment.key().id_or_name()

  if comment.upload_of_work:
    blob_key = comment.upload_of_work.key()

    blob = blobstore.BlobInfo.get(blob_key)
    if blob:
      context['ws_file_blob_key'] = blob_key
      context['ws_file_name'] = blob.filename

    suffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
    file_size_int = blob.size

    for s in suffixes:
      file_size_int /= 1024
      if file_size_int < 1024:
{'fraction_non_alphanumeric': 0.10995850622406639, 'fraction_numerical': 0.00933609958506224, 'mean_word_length': 4.149532710280374, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '4556215', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1232, 'n_words': 374}