def _get_types_for_vcard_object(self, object, default_type):
        """
        get list of types for phone number, email or post address
        :param object: vcard class object
        :type object: vobject.vCard
        :param default_type: use if the object contains no type
        :type default_type: str
        :returns: list of type labels
        :rtype: list(str)
        """
        type_list = []
        # try to find label group for custom value type
        if object.group:
            for label in self.vcard.getChildren():
                if label.name == "X-ABLABEL" and label.group == object.group:
                    custom_type = label.value.strip()
                    if custom_type:
                        type_list.append(custom_type)
        # then load type from params dict
        standard_types = object.params.get("TYPE")
        if standard_types is not None:
            if not isinstance(standard_types, list):
                standard_types = [standard_types]
            for type in standard_types:
                type = type.strip()
                if type and type.lower() != "pref":
                    if not type.lower().startswith("x-"):
                        type_list.append(type)
                    elif type[2:].lower() not in [x.lower() for x in type_list]:
                        # add x-custom type in case it's not already added by
                        # custom label for loop above but strip x- before
                        type_list.append(type[2:])
        # try to get pref parameter from vcard version 4.0
        try:
            type_list.append("pref=%d" % int(object.params.get("PREF")[0]))
        except (IndexError, TypeError, ValueError):
            # else try to determine, if type params contain pref attribute
            try:
                for x in object.params.get("TYPE"):
                    if x.lower() == "pref" and "pref" not in type_list:
                        type_list.append("pref")
            except TypeError:
                pass
        # return type_list or default type
        if type_list:
            return type_list
        return [default_type]
def _get_types_for_vcard_object(self, object, default_type):
        """
        get list of types for phone number, email or post address
        :param object: vcard class object
        :type object: vobject.vCard
        :param default_type: use if the object contains no type
        :type default_type: str
        :returns: list of type labels
        :rtype: list(str)
        """
        type_list = []
        # try to find label group for custom value type
        if object.group:
            for label in self.vcard.getChildren():
                if label.name == "X-ABLABEL" and label.group == object.group:
                    custom_type = label.value.strip()
                    if custom_type:
                        type_list.append(custom_type)
        # then load type from params dict
        standard_types = object.params.get("TYPE")
        if standard_types is not None:
            if not isinstance(standard_types, list):
                standard_types = [standard_types]
            for type in standard_types:
                type = type.strip()
                if type and type.lower() != "pref":
                    if not type.lower().startswith("x-"):
                        type_list.append(type)
                    elif type[2:].lower() not in [x.lower() for x in type_list]:
                        # add x-custom type in case it's not already added by
                        # custom label for loop above but strip x- before
                        type_list.append(type[2:])
        # try to get pref parameter from vcard version 4.0
        try:
            type_list.append("pref=%d" % int(object.params.get("PREF")[0]))
        except (IndexError, TypeError, ValueError):
            # else try to determine, if type params contain pref attribute
            try:
                for x in object.params.get("TYPE"):
                    if x.lower() == "pref" and "pref" not in type_list:
                        type_list.append("pref")
            except TypeError:
                pass
        # return type_list or default type
        if type_list:
            return type_list
        return [default_type]
def _get_types_for_vcard_object ( self , object , default_type ) : type_list = [ ] # try to find label group for custom value type if object . group : for label in self . vcard . getChildren ( ) : if label . name == "X-ABLABEL" and label . group == object . group : custom_type = label . value . strip ( ) if custom_type : type_list . append ( custom_type ) # then load type from params dict standard_types = object . params . get ( "TYPE" ) if standard_types is not None : if not isinstance ( standard_types , list ) : standard_types = [ standard_types ] for type in standard_types : type = type . strip ( ) if type and type . lower ( ) != "pref" : if not type . lower ( ) . startswith ( "x-" ) : type_list . append ( type ) elif type [ 2 : ] . lower ( ) not in [ x . lower ( ) for x in type_list ] : # add x-custom type in case it's not already added by # custom label for loop above but strip x- before type_list . append ( type [ 2 : ] ) # try to get pref parameter from vcard version 4.0 try : type_list . append ( "pref=%d" % int ( object . params . get ( "PREF" ) [ 0 ] ) ) except ( IndexError , TypeError , ValueError ) : # else try to determine, if type params contain pref attribute try : for x in object . params . get ( "TYPE" ) : if x . lower ( ) == "pref" and "pref" not in type_list : type_list . append ( "pref" ) except TypeError : pass # return type_list or default type if type_list : return type_list return [ default_type ]
get list of types for phone number, email or post address
        :param object: vcard class object
        :type object: vobject.vCard
        :param default_type: use if the object contains no type
        :type default_type: str
        :returns: list of type labels
        :rtype: list(str)
get list of types for phone number email or post address : param object : vcard class object : type object : vobject . vCard : param default_type : use if the object contains no type : type default_type : str : returns : list of type labels : rtype : list ( str )