Returns a data oneof's field from plugin_data.content. Raises HParamsError if the content doesn't have 'data_oneof_field' set or this file is incompatible with the version of the metadata stored. Args: content: The SummaryMetadata.plugin_data.content to use. data_oneof_fiel
(content, data_oneof_field)
| 104 | |
| 105 | |
| 106 | def _parse_plugin_data_as(content, data_oneof_field): |
| 107 | """Returns a data oneof's field from plugin_data.content. |
| 108 | |
| 109 | Raises HParamsError if the content doesn't have 'data_oneof_field' set or |
| 110 | this file is incompatible with the version of the metadata stored. |
| 111 | |
| 112 | Args: |
| 113 | content: The SummaryMetadata.plugin_data.content to use. |
| 114 | data_oneof_field: string. The name of the data oneof field to return. |
| 115 | """ |
| 116 | plugin_data = plugin_data_pb2.HParamsPluginData.FromString(content) |
| 117 | if plugin_data.version != PLUGIN_DATA_VERSION: |
| 118 | raise error.HParamsError( |
| 119 | "Only supports plugin_data version: %s; found: %s in: %s" |
| 120 | % (PLUGIN_DATA_VERSION, plugin_data.version, plugin_data) |
| 121 | ) |
| 122 | if not plugin_data.HasField(data_oneof_field): |
| 123 | raise error.HParamsError( |
| 124 | "Expected plugin_data.%s to be set. Got: %s" |
| 125 | % (data_oneof_field, plugin_data) |
| 126 | ) |
| 127 | return getattr(plugin_data, data_oneof_field) |
no outgoing calls
no test coverage detected
searching dependent graphs…