| Index: tools/grit/grit/gather/regexp.py
 | 
| diff --git a/tools/grit/grit/gather/regexp.py b/tools/grit/grit/gather/regexp.py
 | 
| index 88c7413ad816a20f5ece4c73db2cab9b12fbc5d8..150a7774a5b69947898ffcaa04ff548e3895adb3 100644
 | 
| --- a/tools/grit/grit/gather/regexp.py
 | 
| +++ b/tools/grit/grit/gather/regexp.py
 | 
| @@ -9,12 +9,12 @@
 | 
|  import re
 | 
|  import types
 | 
|  
 | 
| -from grit.gather import interface
 | 
| +from grit.gather import skeleton_gatherer
 | 
|  from grit import clique
 | 
|  from grit import tclib
 | 
|  
 | 
|  
 | 
| -class RegexpGatherer(interface.GathererBase):
 | 
| +class RegexpGatherer(skeleton_gatherer.SkeletonGatherer):
 | 
|    '''Common functionality of gatherers based on parsing using a single
 | 
|    regular expression.
 | 
|    '''
 | 
| @@ -32,81 +32,9 @@ class RegexpGatherer(interface.GathererBase):
 | 
|      }
 | 
|  
 | 
|    def __init__(self, text):
 | 
| -    interface.GathererBase.__init__(self)
 | 
| +    skeleton_gatherer.SkeletonGatherer.__init__(self)
 | 
|      # Original text of what we're parsing
 | 
|      self.text_ = text.strip()
 | 
| -    # List of parts of the document. Translateable parts are clique.MessageClique
 | 
| -    # objects, nontranslateable parts are plain strings. Translated messages are
 | 
| -    # inserted back into the skeleton using the quoting rules defined by
 | 
| -    # self.Escape()
 | 
| -    self.skeleton_ = []
 | 
| -    # A list of the names of IDs that need to be defined for this resource
 | 
| -    # section to compile correctly.
 | 
| -    self.ids_ = []
 | 
| -    # True if Parse() has already been called.
 | 
| -    self.have_parsed_ = False
 | 
| -    # True if a translatable chunk has been added
 | 
| -    self.translatable_chunk_ = False
 | 
| -    # If not None, all parts of the document will be put into this single
 | 
| -    # message; otherwise the normal skeleton approach is used.
 | 
| -    self.single_message_ = None
 | 
| -    # Number to use for the next placeholder name.  Used only if single_message
 | 
| -    # is not None
 | 
| -    self.ph_counter_ = 1
 | 
| -
 | 
| -  def GetText(self):
 | 
| -    '''Returns the original text of the section'''
 | 
| -    return self.text_
 | 
| -
 | 
| -  def Escape(self, text):
 | 
| -    '''Subclasses can override.  Base impl is identity.
 | 
| -    '''
 | 
| -    return text
 | 
| -
 | 
| -  def UnEscape(self, text):
 | 
| -    '''Subclasses can override. Base impl is identity.
 | 
| -    '''
 | 
| -    return text
 | 
| -
 | 
| -  def GetTextualIds(self):
 | 
| -    '''Returns the list of textual IDs that need to be defined for this
 | 
| -    resource section to compile correctly.'''
 | 
| -    return self.ids_
 | 
| -
 | 
| -  def GetCliques(self):
 | 
| -    '''Returns the message cliques for each translateable message in the
 | 
| -    resource section.'''
 | 
| -    return filter(lambda x: isinstance(x, clique.MessageClique), self.skeleton_)
 | 
| -
 | 
| -  def Translate(self, lang, pseudo_if_not_available=True,
 | 
| -                skeleton_gatherer=None, fallback_to_english=False):
 | 
| -    if len(self.skeleton_) == 0:
 | 
| -      raise exception.NotReady()
 | 
| -    if skeleton_gatherer:
 | 
| -      assert len(skeleton_gatherer.skeleton_) == len(self.skeleton_)
 | 
| -
 | 
| -    out = []
 | 
| -    for ix in range(len(self.skeleton_)):
 | 
| -      if isinstance(self.skeleton_[ix], types.StringTypes):
 | 
| -        if skeleton_gatherer:
 | 
| -          # Make sure the skeleton is like the original
 | 
| -          assert(isinstance(skeleton_gatherer.skeleton_[ix], types.StringTypes))
 | 
| -          out.append(skeleton_gatherer.skeleton_[ix])
 | 
| -        else:
 | 
| -          out.append(self.skeleton_[ix])
 | 
| -      else:
 | 
| -        if skeleton_gatherer:  # Make sure the skeleton is like the original
 | 
| -          assert(not isinstance(skeleton_gatherer.skeleton_[ix],
 | 
| -                                types.StringTypes))
 | 
| -        msg = self.skeleton_[ix].MessageForLanguage(lang,
 | 
| -                                                    pseudo_if_not_available,
 | 
| -                                                    fallback_to_english)
 | 
| -
 | 
| -        def MyEscape(text):
 | 
| -          return self.Escape(text)
 | 
| -        text = msg.GetRealContent(escaping_function=MyEscape)
 | 
| -        out.append(text)
 | 
| -    return ''.join(out)
 | 
|  
 | 
|    # Contextualization elements. Used for adding additional information
 | 
|    # to the message bundle description string from RC files.
 | 
| @@ -122,37 +50,6 @@ class RegexpGatherer(interface.GathererBase):
 | 
|          message = self.skeleton_[len(self.skeleton_) - 1].GetMessage()
 | 
|          message.SetDescription(description)
 | 
|  
 | 
| -  def Parse(self):
 | 
| -    '''Parses the section.  Implemented by subclasses.  Idempotent.'''
 | 
| -    raise NotImplementedError()
 | 
| -
 | 
| -  def _AddNontranslateableChunk(self, chunk):
 | 
| -    '''Adds a nontranslateable chunk.'''
 | 
| -    if self.single_message_:
 | 
| -      ph = tclib.Placeholder('XX%02dXX' % self.ph_counter_, chunk, chunk)
 | 
| -      self.ph_counter_ += 1
 | 
| -      self.single_message_.AppendPlaceholder(ph)
 | 
| -    else:
 | 
| -      self.skeleton_.append(chunk)
 | 
| -
 | 
| -  def _AddTranslateableChunk(self, chunk):
 | 
| -    '''Adds a translateable chunk.  It will be unescaped before being added.'''
 | 
| -    # We don't want empty messages since they are redundant and the TC
 | 
| -    # doesn't allow them.
 | 
| -    if chunk == '':
 | 
| -      return
 | 
| -
 | 
| -    unescaped_text = self.UnEscape(chunk)
 | 
| -    if self.single_message_:
 | 
| -      self.single_message_.AppendText(unescaped_text)
 | 
| -    else:
 | 
| -      self.skeleton_.append(self.uberclique.MakeClique(
 | 
| -        tclib.Message(text=unescaped_text)))
 | 
| -      self.translatable_chunk_ = True
 | 
| -
 | 
| -  def _AddTextualId(self, id):
 | 
| -    self.ids_.append(id)
 | 
| -
 | 
|    def _RegExpParse(self, regexp, text_to_parse):
 | 
|      '''An implementation of Parse() that can be used for resource sections that
 | 
|      can be parsed using a single multi-line regular expression.
 | 
| 
 |