Ejemplo n.º 1
0
def PyToPB(numobj):
    """Convert phonenumber.PhoneNumber to phonenumber_pb2.PhoneNumber"""
    numpb = PhoneNumberPB()
    if numobj.country_code is not None:
        numpb.country_code = numobj.country_code
    if numobj.national_number is not None:
        numpb.national_number = numobj.national_number
    if numobj.extension is not None:
        numpb.extension = numobj.extension
    if numobj.italian_leading_zero is not None:
        numpb.italian_leading_zero = numobj.italian_leading_zero
    if numobj.number_of_leading_zeros is not None:
        numpb.number_of_leading_zeros = numobj.number_of_leading_zeros
    if numobj.raw_input is not None:
        numpb.raw_input = numobj.raw_input
    if numobj.country_code_source is not None:
        numpb.country_code_source = numobj.country_code_source
    if numobj.preferred_domestic_carrier_code is not None:
        numpb.preferred_domestic_carrier_code = numobj.preferred_domestic_carrier_code
    return numpb
Ejemplo n.º 2
0
def PyToPB(numobj):
    """Convert phonenumber.PhoneNumber to phonenumber_pb2.PhoneNumber"""
    numpb = PhoneNumberPB()
    if numobj.country_code is not None:
        numpb.country_code = numobj.country_code
    if numobj.national_number is not None:
        numpb.national_number = numobj.national_number
    if numobj.extension is not None:
        numpb.extension = numobj.extension
    if numobj.italian_leading_zero is not None:
        numpb.italian_leading_zero = numobj.italian_leading_zero
    if numobj.number_of_leading_zeros is not None:
        numpb.number_of_leading_zeros = numobj.number_of_leading_zeros
    if numobj.raw_input is not None:
        numpb.raw_input = numobj.raw_input
    if numobj.country_code_source is not None:
        numpb.country_code_source = numobj.country_code_source
    if numobj.preferred_domestic_carrier_code is not None:
        numpb.preferred_domestic_carrier_code = numobj.preferred_domestic_carrier_code
    return numpb
def PyToPB(numobj):
    """Convert phonenumber.PhoneNumber to phonenumber_pb2.PhoneNumber"""
    numpb = PhoneNumberPB()
    if numobj.country_code is not None:
        numpb.country_code = numobj.country_code
    if numobj.national_number is not None:
        numpb.national_number = numobj.national_number
    if numobj.extension is not None:
        numpb.extension = numobj.extension
    # For italian_leading_zero, the Python object has two states (True/False),
    # but the protobuf version has three states (True/False/NotSet), and the
    # NotSet state is effectively False.
    numpb.italian_leading_zero = numobj.italian_leading_zero
    if numobj.raw_input is not None:
        numpb.raw_input = numobj.raw_input
    if numobj.country_code_source is not None:
        numpb.country_code_source = numobj.country_code_source
    if numobj.preferred_domestic_carrier_code is not None:
        numpb.preferred_domestic_carrier_code = numobj.preferred_domestic_carrier_code
    return numpb
Ejemplo n.º 4
0
def PyToPB(numobj):
    """Convert phonenumber.PhoneNumber to phonenumber_pb2.PhoneNumber"""
    numpb = PhoneNumberPB()
    if numobj.country_code is not None:
        numpb.country_code = numobj.country_code
    if numobj.national_number is not None:
        numpb.national_number = numobj.national_number
    if numobj.extension is not None:
        numpb.extension = numobj.extension
    # For italian_leading_zero, the Python object has two states (True/False),
    # but the protobuf version has three states (True/False/NotSet), and the
    # NotSet state is effectively False.
    numpb.italian_leading_zero = numobj.italian_leading_zero
    if numobj.raw_input is not None:
        numpb.raw_input = numobj.raw_input
    if numobj.country_code_source is not None:
        numpb.country_code_source = numobj.country_code_source
    if numobj.preferred_domestic_carrier_code is not None:
        numpb.preferred_domestic_carrier_code = numobj.preferred_domestic_carrier_code
    return numpb