'Set the fields for the new job object.
Method takes in a tko job and an empty protocol buffer job
object.  Then safely sets all the appropriate field by first
testing if the value in the original object is None.
:param
tko_job: a tko job instance that will have it\'s values
transferred to the new job
pb_job: a new instance of the job class provided in the
protocol buffer.
tag: used to set pb_job.tag and pb_job.afe_job_id.'

def set_pb_job(self, tko_job, pb_job, tag):

    self.set_trivial_attr(tko_job, pb_job, self.job_type_dict)
    self.set_afe_job_id_and_tag(pb_job, tag)
    for test in tko_job.tests:
        newtest = pb_job.tests.add()
        self.set_pb_test(test, newtest)
    for (key, val) in tko_job.keyval_dict.iteritems():
        newkeyval = pb_job.keyval_dict.add()
        newkeyval.name = key
        newkeyval.value = str(val)
