mojo/public/tools/bindings/mojom_types_downgrader.py
def DowngradeFile(path, output_dir=None):
  """Downgrades the mojom file specified by |path| to the old mojo types.

  Optionally pass |output_dir| to place the result under a separate output
  directory, preserving the relative path to the file included in |path|.
  """
  # Use a temporary file to dump the new contents after replacing the patterns.
  with open(path) as src_mojo_file:
    with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_mojo_file:
      tmp_contents = _REGEXP_PATTERN.sub(ReplaceFunction, src_mojo_file.read())
      tmp_mojo_file.write(tmp_contents)

  # Files should be placed in the desired output directory
  if output_dir:
    output_filepath = os.path.join(output_dir, os.path.basename(path))
    if not os.path.exists(output_dir):
      os.makedirs(output_dir)
  else:
    output_filepath = path

  # Write the new contents preserving the original file's attributes.
  shutil.copystat(path, tmp_mojo_file.name)
  shutil.move(tmp_mojo_file.name, output_filepath)

  # Make sure to "touch" the new file so that access, modify and change times
  # are always newer than the source file's, otherwise Modify time will be kept
  # as per the call to shutil.copystat(), causing unnecessary generations of the
  # output file in subsequent builds due to ninja considering it dirty.
  os.utime(output_filepath, None)
Downgrades the mojom file specified by |path| to the old mojo types.

  Optionally pass |output_dir| to place the result under a separate output
  directory, preserving the relative path to the file included in |path|.
  
Downgrades the mojom file specified by |path| to the old mojo types.
Optionally pass |output_dir| to place the result under a separate output
directory, preserving the relative path to the file included in |path|.
Downgrades the mojom file specified by |path| to the old mojo types . Optionally pass |output_dir| to place the result under a separate output directory preserving the relative path to the file included in |path| .
def DowngradeFile(path, output_dir=None):
  with open(path) as src_mojo_file:
    with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_mojo_file:
      tmp_contents = _REGEXP_PATTERN.sub(ReplaceFunction, src_mojo_file.read())
      tmp_mojo_file.write(tmp_contents)
  if output_dir:
    output_filepath = os.path.join(output_dir, os.path.basename(path))
    if not os.path.exists(output_dir):
      os.makedirs(output_dir)
  else:
    output_filepath = path
  shutil.copystat(path, tmp_mojo_file.name)
  shutil.move(tmp_mojo_file.name, output_filepath)
  os.utime(output_filepath, None)
def DowngradeFile ( path , output_dir = None ) : with open ( path ) as src_mojo_file : with tempfile . NamedTemporaryFile ( mode = 'w' , delete = False ) as tmp_mojo_file : tmp_contents = _REGEXP_PATTERN . sub ( ReplaceFunction , src_mojo_file . read ( ) ) tmp_mojo_file . write ( tmp_contents ) if output_dir : output_filepath = os . path . join ( output_dir , os . path . basename ( path ) ) if not os . path . exists ( output_dir ) : os . makedirs ( output_dir ) else : output_filepath = path shutil . copystat ( path , tmp_mojo_file . name ) shutil . move ( tmp_mojo_file . name , output_filepath ) os . utime ( output_filepath , None )
Downgrades the mojom file specified by |path| to the old mojo types.
Downgrades the mojom file specified by |path| to the old mojo types .
"""Downgrades the mojom file specified by |path| to the old mojo types.

  Optionally pass |output_dir| to place the result under a separate output
  directory, preserving the relative path to the file included in |path|.
  """ # Use a temporary file to dump the new contents after replacing the patterns. # Files should be placed in the desired output directory # Write the new contents preserving the original file's attributes. # Make sure to "touch" the new file so that access, modify and change times # are always newer than the source file's, otherwise Modify time will be kept # as per the call to shutil.copystat(), causing unnecessary generations of the # output file in subsequent builds due to ninja considering it dirty.
path
output_dir