11320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci# Copyright (c) 2014 The Chromium Authors. All rights reserved.
203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be
303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)# found in the LICENSE file.
403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class ParserInterface(object):
703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  """The interface for parsers."""
803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  def ParseChangelog(self, component_path, range_start, range_end):
1003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    """Parses changelog from the URL stored in the parser object.
1103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
1203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    Args:
1303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      component_path: A string, path of the component. Path is used because
1403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)                      path is unique while component name is not.
1503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      range_start: The start range of the regression.
1603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      range_end: The end range of the regression.
1703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
1803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    Returns:
1903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      A tuple containing revision_map and file_to_revision_map,
2003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      revision_map maps a CL number to a dictionary containing revision
2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      information such as author, commit message and the revision url.
2203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      file_to_revision_map maps a name of a file to a tuple containing the CL
2303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      number and path of the file that CL changes.
2403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    """
2503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    raise NotImplementedError()
2603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
2703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  def ParseLineDiff(self, path, component, file_action, githash):
2803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    """Parses the line diff of the given hash.
2903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
3003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    Args:
3103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      path: The path of the file.
3203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      component: The component the file is from.
3303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      file_action: Whether file is modified, deleted or added.
3403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      githash: The git hashcode to check the line diff.
3503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
3603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    Returns:
3703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      url: The URL of the diff page, returns the changelog page for the
3803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)           file if the diff cannot be retrieved.
3903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      changed_line_numbers: The list of the line numbers that has been
4003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)                            changed.
4103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      changed_line_contents: The content of the changed lines.
4203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    """
4303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    raise NotImplementedError()
4403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
4503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  def ParseBlameInfo(self, component, file_path, line, revision):
461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    """Parses blame information of the given file/line in revision.
4703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
4803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    Args:
4903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      component: The component this line is from.
5003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      file_path: The path of the file.
5103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      line: The line that caused the crash.
5203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      revision: The revision to parse blame information for.
5303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
5403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    Returns:
5503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      The content of the line, the last changed revision of the line, author
5603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      and the url of the revision.
5703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    """
5803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    raise NotImplementedError()
59