tools/android/modularization/convenience/build_gn_editor.py
def replace_variable(self, variable: TargetVariable) -> None:
    """Replaces an existing variable and returns True on success."""
    pattern = re.compile(fr'^\s*{variable.get_name()} =', re.MULTILINE)
    match = pattern.search(self._content)
    if not match:
      raise BuildFileUpdateError(
          f'{self._target_type}("{self._target_name}") variable '
          f'{variable.get_name()} not found. Unable to replace.')

    start = match.end()
    if variable.is_list():
      start, end = _find_block(self._content, start, '[', ']')
    else:
      end = _find_line_end(self._content, start)

    if end <= match.start():
      raise BuildFileUpdateError(
          f'{self._target_type}("{self._target_name}") variable '
          f'{variable.get_name()} invalid. Unable to replace.')

    self._content = (self._content[:match.start()] + variable.serialize() +
                     self._content[end + 1:])
Replaces an existing variable and returns True on success.
Replaces an existing variable and returns True on success.
Replaces an existing variable and returns True on success .
def replace_variable(self, variable: TargetVariable) -> None:
    pattern = re.compile(fr'^\s*{variable.get_name()} =', re.MULTILINE)
    match = pattern.search(self._content)
    if not match:
      raise BuildFileUpdateError(
          f'{self._target_type}("{self._target_name}") variable '
          f'{variable.get_name()} not found. Unable to replace.')
    start = match.end()
    if variable.is_list():
      start, end = _find_block(self._content, start, '[', ']')
    else:
      end = _find_line_end(self._content, start)
    if end <= match.start():
      raise BuildFileUpdateError(
          f'{self._target_type}("{self._target_name}") variable '
          f'{variable.get_name()} invalid. Unable to replace.')
    self._content = (self._content[:match.start()] + variable.serialize() +
                     self._content[end + 1:])
def replace_variable ( self , variable : TargetVariable ) -> None : pattern = re . compile ( fr'^\s*{variable.get_name()} =' , re . MULTILINE ) match = pattern . search ( self . _content ) if not match : raise BuildFileUpdateError ( f'{self._target_type}("{self._target_name}") variable ' f'{variable.get_name()} not found. Unable to replace.' ) start = match . end ( ) if variable . is_list ( ) : start , end = _find_block ( self . _content , start , '[' , ']' ) else : end = _find_line_end ( self . _content , start ) if end <= match . start ( ) : raise BuildFileUpdateError ( f'{self._target_type}("{self._target_name}") variable ' f'{variable.get_name()} invalid. Unable to replace.' ) self . _content = ( self . _content [ : match . start ( ) ] + variable . serialize ( ) + self . _content [ end + 1 : ] )
Replaces an existing variable and returns True on success.
Replaces an existing variable and returns True on success .
"""Replaces an existing variable and returns True on success."""
self
variable
TargetVariable