tools/translation/helper/grd_helper.py
def GetGrdpMessagesFromString(grdp_string):
  """Parses the contents of the grdp file given in grdp_string.

    grd_reader can't parse grdp files directly. Instead, this replaces grd
    specific tags in the input string with grdp specific tags, writes the output
    string in a temporary file and loads the grd from the temporary file.

    This code previously created a temporary directory (using grit.util), wrote
    a temporary grd file pointing to another temporary grdp file that contained
    the input string. This was not testable since os.path.exists is overridden
    in tests and grit.util uses mkdirs which in turn calls os.path.exists. This
    new code works because it doesn't need to check the existence of a path.

    It's expected that a grdp file will not refer to another grdp file via a
    <part> tag. Currently, none of the grdp files in the repository does that.
     """
  replaced_string = grdp_string.replace(
      '<grit-part>',
      """<grit base_dir="." latest_public_release="1" current_release="1">
            <release seq="1">
              <messages fallback_to_english="true">
        """)
  replaced_string = replaced_string.replace(
      '</grit-part>', """</messages>
          </release>
        </grit>""")
  with tempfile.NamedTemporaryFile(delete=False) as f:
    f.write(replaced_string.encode('utf-8'))
    f.close()
    messages = GetGrdMessages(f.name, os.path.dirname(f.name))
    os.remove(f.name)
    return messages
Parses the contents of the grdp file given in grdp_string.

    grd_reader can't parse grdp files directly. Instead, this replaces grd
    specific tags in the input string with grdp specific tags, writes the output
    string in a temporary file and loads the grd from the temporary file.

    This code previously created a temporary directory (using grit.util), wrote
    a temporary grd file pointing to another temporary grdp file that contained
    the input string. This was not testable since os.path.exists is overridden
    in tests and grit.util uses mkdirs which in turn calls os.path.exists. This
    new code works because it doesn't need to check the existence of a path.

    It's expected that a grdp file will not refer to another grdp file via a
    <part> tag. Currently, none of the grdp files in the repository does that.
     
Parses the contents of the grdp file given in grdp_string.
grd_reader can't parse grdp files directly. Instead, this replaces grd
specific tags in the input string with grdp specific tags, writes the output
string in a temporary file and loads the grd from the temporary file.

This code previously created a temporary directory (using grit.util), wrote
a temporary grd file pointing to another temporary grdp file that contained
the input string. This was not testable since os.path.exists is overridden
in tests and grit.util uses mkdirs which in turn calls os.path.exists. This
new code works because it doesn't need to check the existence of a path.

It's expected that a grdp file will not refer to another grdp file via a
 tag. Currently, none of the grdp files in the repository does that.
Parses the contents of the grdp file given in grdp_string . grd_reader can ' t parse grdp files directly . Instead this replaces grd specific tags in the input string with grdp specific tags writes the output string in a temporary file and loads the grd from the temporary file . This code previously created a temporary directory ( using grit . util ) wrote a temporary grd file pointing to another temporary grdp file that contained the input string . This was not testable since os . path . exists is overridden in tests and grit . util uses mkdirs which in turn calls os . path . exists . This new code works because it doesn ' t need to check the existence of a path . It ' s expected that a grdp file will not refer to another grdp file via a tag . Currently none of the grdp files in the repository does that .
def GetGrdpMessagesFromString(grdp_string):
  replaced_string = grdp_string.replace(
      '<grit-part>',
      """<grit base_dir="." latest_public_release="1" current_release="1">
            <release seq="1">
              <messages fallback_to_english="true">
        """)
  replaced_string = replaced_string.replace(
      '</grit-part>', """</messages>
          </release>
        </grit>""")
  with tempfile.NamedTemporaryFile(delete=False) as f:
    f.write(replaced_string.encode('utf-8'))
    f.close()
    messages = GetGrdMessages(f.name, os.path.dirname(f.name))
    os.remove(f.name)
    return messages
def GetGrdpMessagesFromString ( grdp_string ) : replaced_string = grdp_string . replace ( '<grit-part>' , """<grit base_dir="." latest_public_release="1" current_release="1">
            <release seq="1">
              <messages fallback_to_english="true">
        """ ) replaced_string = replaced_string . replace ( '</grit-part>' , """</messages>
          </release>
        </grit>""" ) with tempfile . NamedTemporaryFile ( delete = False ) as f : f . write ( replaced_string . encode ( 'utf-8' ) ) f . close ( ) messages = GetGrdMessages ( f . name , os . path . dirname ( f . name ) ) os . remove ( f . name ) return messages
Parses the contents of the grdp file given in grdp_string.
Parses the contents of the grdp file given in grdp_string .
"""Parses the contents of the grdp file given in grdp_string.

    grd_reader can't parse grdp files directly. Instead, this replaces grd
    specific tags in the input string with grdp specific tags, writes the output
    string in a temporary file and loads the grd from the temporary file.

    This code previously created a temporary directory (using grit.util), wrote
    a temporary grd file pointing to another temporary grdp file that contained
    the input string. This was not testable since os.path.exists is overridden
    in tests and grit.util uses mkdirs which in turn calls os.path.exists. This
    new code works because it doesn't need to check the existence of a path.

    It's expected that a grdp file will not refer to another grdp file via a
    <part> tag. Currently, none of the grdp files in the repository does that.
     """
grdp_string