parameters: (almost_snippet_values, log)
return_statement: return true_snippet_values
docstring: Catchall for converting anything fiddled-with back to pure dbroot form.
  
    Right now just translates enum text to numeric values.
  
    Args:
      almost_snippet_values: snippet values.
      log: logger obj.
    Returns:
      All the snippet values, ready to write to a dbroot.
docstring_summary: Catchall for converting anything fiddled-with back to pure dbroot form.
docstring_tokens: Catchall for converting anything fiddled - with back to pure dbroot form .
function: def _MassageSpecialCases(almost_snippet_values, log):
    """Catchall for converting anything fiddled-with back to pure dbroot form.
  
    Right now just translates enum text to numeric values.
  
    Args:
      almost_snippet_values: snippet values.
      log: logger obj.
    Returns:
      All the snippet values, ready to write to a dbroot.
    """
    log.debug(">massaging...")
    true_snippet_values = []
    assert isinstance(almost_snippet_values, list)
    log.debug("survived assertion")
    dbroot_proto_for_structure = dbroot_utils.MakeEmptyDbroot()
    for concrete_fieldpath, snippet_value in almost_snippet_values:
      log.debug("concrete for no good reason " + concrete_fieldpath)
      abstract_fieldpath = path_utils.AsAbstract(concrete_fieldpath)
      log.debug("abs field:" + abstract_fieldpath)
  
      fdesc = proto_reflection.FieldDescriptorAtFieldPath(
          dbroot_proto_for_structure, abstract_fieldpath)
      log.debug("got field desc")
  
      is_enum = fdesc.enum_type is not None
      log.debug("enum? " + str(is_enum))
      # Special case - on the client we represent /repeated enums/ as a choice of
      # fixed checkboxes. Here, we convert that back.
      if not is_enum:
        # plain
        log.debug("massaging, but plain: " + concrete_fieldpath +
                  " " + str(snippet_value))
        true_snippet_values.append((concrete_fieldpath, snippet_value))
        log.debug("did not massage non-enum")
      else:
        is_repeated = fdesc.label == fdesc.LABEL_REPEATED
        if not is_repeated:
          log.debug("massaging singular enum:" +
                    concrete_fieldpath + snippet_value)
          enum_val = _EnumValFromText(fdesc, snippet_value, log)
          log.debug("massaged singular; " +
                    concrete_fieldpath + " " + str(enum_val))
          true_snippet_values.append((concrete_fieldpath, enum_val))
        else:
          # repeated enum
          log.debug("supposedly repeated enum...name: %s %s" % (
              concrete_fieldpath, str(snippet_value)))
  
          enum_text_vals = _ExtractWidgetEnumTextValues(snippet_value, log)
  
          for i, enum_text in enumerate(enum_text_vals):
            log.debug("enum text: " + enum_text)
            log.debug("all enum vals: " + fdesc.name)
            log.debug("all enum vals: " +
                      str(fdesc.enum_type.values_by_name.keys()))
            enum_val = _EnumValFromText(fdesc, enum_text, log)
            log.debug("whew, found enum val!")
            # need to concretize, now! No way around it.
            log.debug("special enum snippetval: " + snippet_value + "->" +
                      str(enum_val))
            # thank heaven these can only be primitives! (& thus easy to get at)
            added_concrete_fieldpath = concrete_fieldpath + "[%d]" % i
            log.debug("enummed: " + added_concrete_fieldpath)
  
            true_snippet_values.append((added_concrete_fieldpath, enum_val))
        log.debug("massaged enum")
  
    log.debug("done massaging")
    return true_snippet_values
function_tokens: def _MassageSpecialCases ( almost_snippet_values , log ) : log . debug ( ">massaging..." ) true_snippet_values = [ ] assert isinstance ( almost_snippet_values , list ) log . debug ( "survived assertion" ) dbroot_proto_for_structure = dbroot_utils . MakeEmptyDbroot ( ) for concrete_fieldpath , snippet_value in almost_snippet_values : log . debug ( "concrete for no good reason " + concrete_fieldpath ) abstract_fieldpath = path_utils . AsAbstract ( concrete_fieldpath ) log . debug ( "abs field:" + abstract_fieldpath ) fdesc = proto_reflection . FieldDescriptorAtFieldPath ( dbroot_proto_for_structure , abstract_fieldpath ) log . debug ( "got field desc" ) is_enum = fdesc . enum_type is not None log . debug ( "enum? " + str ( is_enum ) ) # Special case - on the client we represent /repeated enums/ as a choice of # fixed checkboxes. Here, we convert that back. if not is_enum : # plain log . debug ( "massaging, but plain: " + concrete_fieldpath + " " + str ( snippet_value ) ) true_snippet_values . append ( ( concrete_fieldpath , snippet_value ) ) log . debug ( "did not massage non-enum" ) else : is_repeated = fdesc . label == fdesc . LABEL_REPEATED if not is_repeated : log . debug ( "massaging singular enum:" + concrete_fieldpath + snippet_value ) enum_val = _EnumValFromText ( fdesc , snippet_value , log ) log . debug ( "massaged singular; " + concrete_fieldpath + " " + str ( enum_val ) ) true_snippet_values . append ( ( concrete_fieldpath , enum_val ) ) else : # repeated enum log . debug ( "supposedly repeated enum...name: %s %s" % ( concrete_fieldpath , str ( snippet_value ) ) ) enum_text_vals = _ExtractWidgetEnumTextValues ( snippet_value , log ) for i , enum_text in enumerate ( enum_text_vals ) : log . debug ( "enum text: " + enum_text ) log . debug ( "all enum vals: " + fdesc . name ) log . debug ( "all enum vals: " + str ( fdesc . enum_type . values_by_name . keys ( ) ) ) enum_val = _EnumValFromText ( fdesc , enum_text , log ) log . debug ( "whew, found enum val!" ) # need to concretize, now! No way around it. log . debug ( "special enum snippetval: " + snippet_value + "->" + str ( enum_val ) ) # thank heaven these can only be primitives! (& thus easy to get at) added_concrete_fieldpath = concrete_fieldpath + "[%d]" % i log . debug ( "enummed: " + added_concrete_fieldpath ) true_snippet_values . append ( ( added_concrete_fieldpath , enum_val ) ) log . debug ( "massaged enum" ) log . debug ( "done massaging" ) return true_snippet_values