mojo/public/tools/mojom/mojom/generate/module.py
def Repr(obj, as_ref=True):
  """A version of __repr__ that can distinguish references.

  Sometimes we like to print an object's full representation
  (e.g. with its fields) and sometimes we just want to reference an
  object that was printed in full elsewhere. This function allows us
  to make that distinction.

  Args:
    obj: The object whose string representation we compute.
    as_ref: If True, use the short reference representation.

  Returns:
    A str representation of |obj|.
  """
  if hasattr(obj, 'Repr'):
    return obj.Repr(as_ref=as_ref)
  # Since we cannot implement Repr for existing container types, we
  # handle them here.
  elif isinstance(obj, list):
    if not obj:
      return '[]'
    else:
      return ('[\n%s\n]' % (',\n'.join(
          '    %s' % Repr(elem, as_ref).replace('\n', '\n    ')
          for elem in obj)))
  elif isinstance(obj, dict):
    if not obj:
      return '{}'
    else:
      return ('{\n%s\n}' % (',\n'.join(
          '    %s: %s' % (Repr(key, as_ref).replace('\n', '\n    '),
                          Repr(val, as_ref).replace('\n', '\n    '))
          for key, val in obj.items())))
  else:
    return repr(obj)
A version of __repr__ that can distinguish references.

  Sometimes we like to print an object's full representation
  (e.g. with its fields) and sometimes we just want to reference an
  object that was printed in full elsewhere. This function allows us
  to make that distinction.

  Args:
    obj: The object whose string representation we compute.
    as_ref: If True, use the short reference representation.

  Returns:
    A str representation of |obj|.
  
A version of __repr__ that can distinguish references.
Sometimes we like to print an object's full representation
and sometimes we just want to reference an
object that was printed in full elsewhere. This function allows us
to make that distinction.
A version of __repr__ that can distinguish references . Sometimes we like to print an object ' s full representation and sometimes we just want to reference an object that was printed in full elsewhere . This function allows us to make that distinction .
def Repr(obj, as_ref=True):
  if hasattr(obj, 'Repr'):
    return obj.Repr(as_ref=as_ref)
  elif isinstance(obj, list):
    if not obj:
      return '[]'
    else:
      return ('[\n%s\n]' % (',\n'.join(
          '    %s' % Repr(elem, as_ref).replace('\n', '\n    ')
          for elem in obj)))
  elif isinstance(obj, dict):
    if not obj:
      return '{}'
    else:
      return ('{\n%s\n}' % (',\n'.join(
          '    %s: %s' % (Repr(key, as_ref).replace('\n', '\n    '),
                          Repr(val, as_ref).replace('\n', '\n    '))
          for key, val in obj.items())))
  else:
    return repr(obj)
def Repr ( obj , as_ref = True ) : if hasattr ( obj , 'Repr' ) : return obj . Repr ( as_ref = as_ref ) elif isinstance ( obj , list ) : if not obj : return '[]' else : return ( '[\n%s\n]' % ( ',\n' . join ( '    %s' % Repr ( elem , as_ref ) . replace ( '\n' , '\n    ' ) for elem in obj ) ) ) elif isinstance ( obj , dict ) : if not obj : return '{}' else : return ( '{\n%s\n}' % ( ',\n' . join ( '    %s: %s' % ( Repr ( key , as_ref ) . replace ( '\n' , '\n    ' ) , Repr ( val , as_ref ) . replace ( '\n' , '\n    ' ) ) for key , val in obj . items ( ) ) ) ) else : return repr ( obj )
A version of __repr__ that can distinguish references.
A version of __repr__ that can distinguish references .
"""A version of __repr__ that can distinguish references.

  Sometimes we like to print an object's full representation
  (e.g. with its fields) and sometimes we just want to reference an
  object that was printed in full elsewhere. This function allows us
  to make that distinction.

  Args:
    obj: The object whose string representation we compute.
    as_ref: If True, use the short reference representation.

  Returns:
    A str representation of |obj|.
  """ # Since we cannot implement Repr for existing container types, we # handle them here.
A str representation of |obj|.
A str representation of |obj| .
obj
The object whose string representation we compute.
The object whose string representation we compute .
as_ref
If True, use the short reference representation.
If True use the short reference representation .