コード例 #1
0
ファイル: encoding_test.py プロジェクト: nylas/flanker
def string_maxlinelen_test():
    """
    If the encoded string is longer then the maximum line length, which is 76,
    by default then it is broken down into lines. But a maximum line length
    value can be provided in the `maxlinelen` parameter.
    """
    eq_("very\n loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
        encode_string(None, "very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"))

    eq_("very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
        encode_string(None, "very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong", maxlinelen=78))
コード例 #2
0
ファイル: message.py プロジェクト: nylas/sync-engine
def _get_full_spec_without_validation(name, email):
    """
    This function is the same as calling full_spec() on
    a Flanker address.EmailAddress object. This function exists
    because you can't construct a Flanker EmailAddress object with
    an invalid email address.
    """
    if name:
        encoded_name = smart_quote(encode_string(
            None, name, maxlinelen=MAX_ADDRESS_LENGTH))
        return '{0} <{1}>'.format(encoded_name, email)
    return u'{0}'.format(email)
コード例 #3
0
ファイル: address.py プロジェクト: hartym/flanker
    def full_spec(self):
        """
        Returns a full spec of an email address. Always in ASCII, RFC-2822
        compliant, safe to be included into MIME:

           >>> EmailAddress("Ev K", "[email protected]").full_spec()
           'Ev K <[email protected]>'
           >>> EmailAddress("Жека", "[email protected]").full_spec()
           '=?utf-8?b?0JbQtdC60LA=?= <[email protected]>'
        """
        if self.display_name:
            encoded_display_name = smart_quote(encode_string(
                None, self.display_name, maxlinelen=MAX_ADDRESS_LENGTH))
            return '{0} <{1}>'.format(encoded_display_name, self.address)
        return '{0}'.format(self.address)
コード例 #4
0
ファイル: parser.py プロジェクト: AnSavvides/flanker
    def _word_unicode(self):
        "Grammar: word-unicode -> unicode-atom | unicode-qstring"
        start_pos = self.stream.position

        # unicode atom
        uwrd = self.stream.get_token(UNI_ATOM)
        if uwrd and isinstance(uwrd, unicode) and not contains_control_chars(uwrd):
            return uwrd

        # unicode qstr
        uwrd = self.stream.get_token(UNI_QSTR, 'qstr')
        if uwrd and isinstance(uwrd, unicode) and not contains_control_chars(uwrd):
            return u'"{}"'.format(encode_string(None, uwrd))

        # rollback
        self.stream.position = start_pos
        return None
コード例 #5
0
ファイル: address.py プロジェクト: UtahDave/flanker
    def __init__(self, display_name, spec=None):
        if spec is None:
            spec = display_name
            display_name = None

        assert(spec)

        if display_name is None:
            self.display_name = u''
        else:
            self.display_name = encode_string(None, display_name)

        parts = spec.rsplit('@', 1)
        self.mailbox = parts[0]
        self.hostname = parts[1].lower()
        self.address = self.mailbox + "@" + self.hostname
        self.addr_type = self.Type.Email
コード例 #6
0
ファイル: address.py プロジェクト: nylas/flanker
 def ace_display_name(self):
     return encode_string(None, smart_quote(self.display_name),
                          maxlinelen=MAX_ADDRESS_LENGTH)