testing/unexpected_passes_common/result_output.py
def _OutputUrlsForClDescription(affected_urls, orphaned_urls, file_handle=None):
  """Outputs |urls| for use in a CL description.

  Output adheres to the line length recommendation and max number of bugs per
  line supported in Gerrit.

  Args:
    affected_urls: A list of strings containing URLs to output.
    orphaned_urls: A list of strings containing URLs to output as closable.
    file_handle: A file handle to write the string to. Defaults to stdout.
  """

  def AddBugTypeToOutputString(urls, prefix):
    output_str = ''
    current_line = ''
    bugs_on_line = 0

    urls = collections.deque(urls)

    while len(urls):
      current_bug = urls.popleft()
      current_bug = current_bug.split('crbug.com/', 1)[1]
      # Handles cases like crbug.com/angleproject/1234.
      current_bug = current_bug.replace('/', ':')

      # First bug on the line.
      if not current_line:
        current_line = '%s %s' % (prefix, current_bug)
      # Bug or length limit hit for line.
      elif (
          len(current_line) + len(current_bug) + 2 > MAX_CHARACTERS_PER_CL_LINE
          or bugs_on_line >= MAX_BUGS_PER_LINE):
        output_str += current_line + '\n'
        bugs_on_line = 0
        current_line = '%s %s' % (prefix, current_bug)
      # Can add to current line.
      else:
        current_line += ', %s' % current_bug

      bugs_on_line += 1

    output_str += current_line + '\n'
    return output_str

  file_handle = file_handle or sys.stdout
  affected_but_not_closable = set(affected_urls) - set(orphaned_urls)
  affected_but_not_closable = list(affected_but_not_closable)
  affected_but_not_closable.sort()

  output_str = ''
  if affected_but_not_closable:
    output_str += AddBugTypeToOutputString(affected_but_not_closable, 'Bug:')
  if orphaned_urls:
    output_str += AddBugTypeToOutputString(orphaned_urls, 'Fixed:')

  file_handle.write('Affected bugs for CL description:\n%s' % output_str)
Outputs |urls| for use in a CL description.

  Output adheres to the line length recommendation and max number of bugs per
  line supported in Gerrit.

  Args:
    affected_urls: A list of strings containing URLs to output.
    orphaned_urls: A list of strings containing URLs to output as closable.
    file_handle: A file handle to write the string to. Defaults to stdout.
  
Outputs |urls| for use in a CL description.
Output adheres to the line length recommendation and max number of bugs per
line supported in Gerrit.
Outputs |urls| for use in a CL description . Output adheres to the line length recommendation and max number of bugs per line supported in Gerrit .
def _OutputUrlsForClDescription(affected_urls, orphaned_urls, file_handle=None):
  def AddBugTypeToOutputString(urls, prefix):
    output_str = ''
    current_line = ''
    bugs_on_line = 0
    urls = collections.deque(urls)
    while len(urls):
      current_bug = urls.popleft()
      current_bug = current_bug.split('crbug.com/', 1)[1]
      current_bug = current_bug.replace('/', ':')
      if not current_line:
        current_line = '%s %s' % (prefix, current_bug)
      elif (
          len(current_line) + len(current_bug) + 2 > MAX_CHARACTERS_PER_CL_LINE
          or bugs_on_line >= MAX_BUGS_PER_LINE):
        output_str += current_line + '\n'
        bugs_on_line = 0
        current_line = '%s %s' % (prefix, current_bug)
      else:
        current_line += ', %s' % current_bug
      bugs_on_line += 1
    output_str += current_line + '\n'
    return output_str
  file_handle = file_handle or sys.stdout
  affected_but_not_closable = set(affected_urls) - set(orphaned_urls)
  affected_but_not_closable = list(affected_but_not_closable)
  affected_but_not_closable.sort()
  output_str = ''
  if affected_but_not_closable:
    output_str += AddBugTypeToOutputString(affected_but_not_closable, 'Bug:')
  if orphaned_urls:
    output_str += AddBugTypeToOutputString(orphaned_urls, 'Fixed:')
  file_handle.write('Affected bugs for CL description:\n%s' % output_str)
def _OutputUrlsForClDescription ( affected_urls , orphaned_urls , file_handle = None ) : def AddBugTypeToOutputString ( urls , prefix ) : output_str = '' current_line = '' bugs_on_line = 0 urls = collections . deque ( urls ) while len ( urls ) : current_bug = urls . popleft ( ) current_bug = current_bug . split ( 'crbug.com/' , 1 ) [ 1 ] current_bug = current_bug . replace ( '/' , ':' ) if not current_line : current_line = '%s %s' % ( prefix , current_bug ) elif ( len ( current_line ) + len ( current_bug ) + 2 > MAX_CHARACTERS_PER_CL_LINE or bugs_on_line >= MAX_BUGS_PER_LINE ) : output_str += current_line + '\n' bugs_on_line = 0 current_line = '%s %s' % ( prefix , current_bug ) else : current_line += ', %s' % current_bug bugs_on_line += 1 output_str += current_line + '\n' return output_str file_handle = file_handle or sys . stdout affected_but_not_closable = set ( affected_urls ) - set ( orphaned_urls ) affected_but_not_closable = list ( affected_but_not_closable ) affected_but_not_closable . sort ( ) output_str = '' if affected_but_not_closable : output_str += AddBugTypeToOutputString ( affected_but_not_closable , 'Bug:' ) if orphaned_urls : output_str += AddBugTypeToOutputString ( orphaned_urls , 'Fixed:' ) file_handle . write ( 'Affected bugs for CL description:\n%s' % output_str )
Outputs |urls| for use in a CL description.
Outputs |urls| for use in a CL description .
"""Outputs |urls| for use in a CL description.

  Output adheres to the line length recommendation and max number of bugs per
  line supported in Gerrit.

  Args:
    affected_urls: A list of strings containing URLs to output.
    orphaned_urls: A list of strings containing URLs to output as closable.
    file_handle: A file handle to write the string to. Defaults to stdout.
  """ # Handles cases like crbug.com/angleproject/1234. # First bug on the line. # Bug or length limit hit for line. # Can add to current line.
affected_urls
A list of strings containing URLs to output.
A list of strings containing URLs to output .
orphaned_urls
A list of strings containing URLs to output as closable.
A list of strings containing URLs to output as closable .
file_handle
A file handle to write the string to. Defaults to stdout.
A file handle to write the string to . Defaults to stdout .
stdout