Пример #1
0
def _add_billed_ops_to_map(billed_ops_dict, billed_ops_list):
  """Add the BilledOpProtos in billed_ops_list to the given dict."""
  for billed_op in billed_ops_list:
    if billed_op.op() not in billed_ops_dict:
      update_me = datamodel_pb.BilledOpProto()
      update_me.set_op(billed_op.op())
      update_me.set_num_ops(0)
      billed_ops_dict[billed_op.op()] = update_me
    update_me = billed_ops_dict[billed_op.op()]
    update_me.set_num_ops(update_me.num_ops() + billed_op.num_ops())
Пример #2
0
def _add_billed_ops_to_map(billed_ops_map, billed_ops_list):
    """Adds the BilledOpProto objects to the given map.

  The map is from BilledOpProto.op to the pb.

  Args:
    billed_ops_map: The map to populate.
    billed_ops_list: List containing the BilledOpProtos to add to the map.
  """
    for billed_op in billed_ops_list:
        if billed_op.op() not in billed_ops_map:
            update_me = datamodel_pb.BilledOpProto()
            update_me.set_op(billed_op.op())
            update_me.set_num_ops(0)
            billed_ops_map[billed_op.op()] = update_me
        update_me = billed_ops_map[billed_op.op()]
        update_me.set_num_ops(update_me.num_ops() + billed_op.num_ops())