当前位置: 首页>>代码示例>>Python>>正文


Python message.tell方法代码示例

本文整理汇总了Python中email.message.tell方法的典型用法代码示例。如果您正苦于以下问题:Python message.tell方法的具体用法?Python message.tell怎么用?Python message.tell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在email.message的用法示例。


在下文中一共展示了message.tell方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate_toc

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def _generate_toc(self):
        """Generate key-to-(start, stop) table of contents."""
        starts, stops = [], []
        self._file.seek(0)
        while True:
            line_pos = self._file.tell()
            line = self._file.readline()
            if line.startswith('From '):
                if len(stops) < len(starts):
                    stops.append(line_pos - len(os.linesep))
                starts.append(line_pos)
            elif line == '':
                stops.append(line_pos)
                break
        self._toc = dict(enumerate(zip(starts, stops)))
        self._next_key = len(self._toc)
        self._file_length = self._file.tell() 
开发者ID:glmcdona,项目名称:meddle,代码行数:19,代码来源:mailbox.py

示例2: get_message

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def get_message(self, key):
        """Return a Message representation or raise a KeyError."""
        start, stop = self._lookup(key)
        self._file.seek(start)
        self._file.readline()   # Skip '1,' line specifying labels.
        original_headers = StringIO.StringIO()
        while True:
            line = self._file.readline()
            if line == '*** EOOH ***' + os.linesep or line == '':
                break
            original_headers.write(line.replace(os.linesep, '\n'))
        visible_headers = StringIO.StringIO()
        while True:
            line = self._file.readline()
            if line == os.linesep or line == '':
                break
            visible_headers.write(line.replace(os.linesep, '\n'))
        body = self._file.read(stop - self._file.tell()).replace(os.linesep,
                                                                 '\n')
        msg = BabylMessage(original_headers.getvalue() + body)
        msg.set_visible(visible_headers.getvalue())
        if key in self._labels:
            msg.set_labels(self._labels[key])
        return msg 
开发者ID:glmcdona,项目名称:meddle,代码行数:26,代码来源:mailbox.py

示例3: get_string

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def get_string(self, key):
        """Return a string representation or raise a KeyError."""
        start, stop = self._lookup(key)
        self._file.seek(start)
        self._file.readline()   # Skip '1,' line specifying labels.
        original_headers = StringIO.StringIO()
        while True:
            line = self._file.readline()
            if line == '*** EOOH ***' + os.linesep or line == '':
                break
            original_headers.write(line.replace(os.linesep, '\n'))
        while True:
            line = self._file.readline()
            if line == os.linesep or line == '':
                break
        return original_headers.getvalue() + \
               self._file.read(stop - self._file.tell()).replace(os.linesep,
                                                                 '\n') 
开发者ID:glmcdona,项目名称:meddle,代码行数:20,代码来源:mailbox.py

示例4: _append_message

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def _append_message(self, message):
        """Append message to mailbox and return (start, stop) offsets."""
        self._file.seek(0, 2)
        before = self._file.tell()
        if len(self._toc) == 0 and not self._pending:
            # This is the first message, and the _pre_mailbox_hook
            # hasn't yet been called. If self._pending is True,
            # messages have been removed, so _pre_mailbox_hook must
            # have been called already.
            self._pre_mailbox_hook(self._file)
        try:
            self._pre_message_hook(self._file)
            offsets = self._install_message(message)
            self._post_message_hook(self._file)
        except BaseException:
            self._file.truncate(before)
            raise
        self._file.flush()
        self._file_length = self._file.tell()  # Record current length of mailbox
        return offsets 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:mailbox.py

示例5: next

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def next(self):
        while 1:
            self.fp.seek(self.seekp)
            try:
                self._search_start()
            except EOFError:
                self.seekp = self.fp.tell()
                return None
            start = self.fp.tell()
            self._search_end()
            self.seekp = stop = self.fp.tell()
            if start != stop:
                break
        return self.factory(_PartialFile(self.fp, start, stop))

# Recommended to use PortableUnixMailbox instead! 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:mailbox.py

示例6: _append_message

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def _append_message(self, message):
        """Append message to mailbox and return (start, stop) offsets."""
        self._file.seek(0, 2)
        before = self._file.tell()
        try:
            self._pre_message_hook(self._file)
            offsets = self._install_message(message)
            self._post_message_hook(self._file)
        except BaseException:
            self._file.truncate(before)
            raise
        self._file.flush()
        self._file_length = self._file.tell()  # Record current length of mailbox
        return offsets 
开发者ID:glmcdona,项目名称:meddle,代码行数:16,代码来源:mailbox.py

示例7: get_file

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def get_file(self, key, from_=False):
        """Return a file-like representation or raise a KeyError."""
        start, stop = self._lookup(key)
        self._file.seek(start)
        if not from_:
            self._file.readline()
        return _PartialFile(self._file, self._file.tell(), stop) 
开发者ID:glmcdona,项目名称:meddle,代码行数:9,代码来源:mailbox.py

示例8: _pre_message_hook

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def _pre_message_hook(self, f):
        """Called before writing each message to file f."""
        if f.tell() != 0:
            f.write(os.linesep) 
开发者ID:glmcdona,项目名称:meddle,代码行数:6,代码来源:mailbox.py

示例9: __init__

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def __init__(self, f, pos=None):
        """Initialize a _ProxyFile."""
        self._file = f
        if pos is None:
            self._pos = f.tell()
        else:
            self._pos = pos 
开发者ID:glmcdona,项目名称:meddle,代码行数:9,代码来源:mailbox.py

示例10: tell

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def tell(self):
        """Return the position."""
        return self._pos 
开发者ID:glmcdona,项目名称:meddle,代码行数:5,代码来源:mailbox.py

示例11: seek

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def seek(self, offset, whence=0):
        """Change position."""
        if whence == 1:
            self._file.seek(self._pos)
        self._file.seek(offset, whence)
        self._pos = self._file.tell() 
开发者ID:glmcdona,项目名称:meddle,代码行数:8,代码来源:mailbox.py

示例12: _read

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def _read(self, size, read_method):
        """Read size bytes using read_method."""
        if size is None:
            size = -1
        self._file.seek(self._pos)
        result = read_method(size)
        self._pos = self._file.tell()
        return result 
开发者ID:glmcdona,项目名称:meddle,代码行数:10,代码来源:mailbox.py

示例13: _search_start

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def _search_start(self):
        while 1:
            pos = self.fp.tell()
            line = self.fp.readline()
            if not line:
                raise EOFError
            if line[:5] == 'From ' and self._isrealfromline(line):
                self.fp.seek(pos)
                return 
开发者ID:glmcdona,项目名称:meddle,代码行数:11,代码来源:mailbox.py

示例14: _search_end

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import tell [as 别名]
def _search_end(self):
        self.fp.readline()      # Throw away header line
        while 1:
            pos = self.fp.tell()
            line = self.fp.readline()
            if not line:
                return
            if line[:5] == 'From ' and self._isrealfromline(line):
                self.fp.seek(pos)
                return

    # An overridable mechanism to test for From-line-ness.  You can either
    # specify a different regular expression or define a whole new
    # _isrealfromline() method.  Note that this only gets called for lines
    # starting with the 5 characters "From ".
    #
    # BAW: According to
    #http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html
    # the only portable, reliable way to find message delimiters in a BSD (i.e
    # Unix mailbox) style folder is to search for "\n\nFrom .*\n", or at the
    # beginning of the file, "^From .*\n".  While _fromlinepattern below seems
    # like a good idea, in practice, there are too many variations for more
    # strict parsing of the line to be completely accurate.
    #
    # _strict_isrealfromline() is the old version which tries to do stricter
    # parsing of the From_ line.  _portable_isrealfromline() simply returns
    # true, since it's never called if the line doesn't already start with
    # "From ".
    #
    # This algorithm, and the way it interacts with _search_start() and
    # _search_end() may not be completely correct, because it doesn't check
    # that the two characters preceding "From " are \n\n or the beginning of
    # the file.  Fixing this would require a more extensive rewrite than is
    # necessary.  For convenience, we've added a PortableUnixMailbox class
    # which does no checking of the format of the 'From' line. 
开发者ID:glmcdona,项目名称:meddle,代码行数:37,代码来源:mailbox.py


注:本文中的email.message.tell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。