MCPcopy Create free account
hub / github.com/ampproject/amphtml / MaybePrintMessageValue

Function MaybePrintMessageValue

validator/validator_gen_js.py:522–540  ·  view source on GitHub ↗

Print field_val if necessary, and return its message reference. Args: descriptor: The descriptor module from the protobuf package, e.g. google.protobuf.descriptor. field_val: The value of a field, a proto message. registry: an instance of MessageRegistry, used for mapping from

(descriptor, field_val, registry, out)

Source from the content-addressed store, hash-verified

520
521
522def MaybePrintMessageValue(descriptor, field_val, registry, out):
523 """Print field_val if necessary, and return its message reference.
524
525 Args:
526 descriptor: The descriptor module from the protobuf package, e.g.
527 google.protobuf.descriptor.
528 field_val: The value of a field, a proto message.
529 registry: an instance of MessageRegistry, used for mapping from
530 messages to message keys.
531 out: a list of lines to output (without the newline characters) wrapped as
532 an OutputFormatter instance, to which this function will append.
533 Returns:
534 This object's message reference, e.g. typically the variable name in
535 validator-generated.js.
536 """
537 message_key = MessageKey(field_val)
538 if not registry.IsPrinted(message_key):
539 PrintObject(descriptor, field_val, registry, out)
540 return registry.MessageReferenceForKey(message_key)
541
542
543def IsTrivialAttrSpec(attr):

Callers 1

AssignedValueForFunction · 0.85

Calls 4

MessageKeyClass · 0.85
PrintObjectFunction · 0.85
IsPrintedMethod · 0.80

Tested by

no test coverage detected