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


Python LogFile.write方法代码示例

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


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

示例1: Main

# 需要导入模块: from goodcrypto.utils.log_file import LogFile [as 别名]
# 或者: from goodcrypto.utils.log_file.LogFile import write [as 别名]

#.........这里部分代码省略.........
        def validate_email(email, role):
            if email is None:
                raise ValidationError(i18n('No email address specified for {role}'.format(
                    role=role)))
            try:
                email_validator = EmailValidator()
                email_validator(email)
            except ValidationError as validation_error:
                self.log_message('Bad {} email address in envelope: {}'.format(role, email))
                raise ValidationError(i18n('Bad {role} email address in envelope: "{email}"'.format(
                    role=role, email=email)))

            return email

        self.log_message('sender: {}'.format(self.sender))
        self.log_message('recipients: {}'.format(self.recipients))
        result_ok = True
        self.sender = validate_email(sender, 'sender')
        for recipient in recipients:
            self.recipients.append(validate_email(recipient, 'recipient'))

        if Main.DEBUGGING:
            self.log_message('sender: {}'.format(self.sender))
            self.log_message('recipients: {}'.format(self.recipients))

        return result_ok

    def read_message_from_stdin(self):
        '''
            Read the message from stdin.

            >>> from test.support import captured_stdin
            >>> with captured_stdin() as stdin:
            ...     bytes = stdin.write('hello')
            ...     position = stdin.seek(0)
            ...     m = Main()
            ...     m.read_message_from_stdin()
            ...     ''.join(m.in_message)
            'hello'
        '''

        message = []
        try:
            """
            in_stream = codecs.getreader('utf-8')(sys.stdin)
            done = False
            while not done:
                line = in_stream.readline()
                self.log_message('{}'.format(line))
                self.log_message('{}'.format(type(line)))
                message.append(line)
            """
            done = False
            while not done:
                try:
                    line = input()
                    message.append(line)

                    if Main.DEBUGGING:
                        self.log_message(line)
                except UnicodeDecodeError:
                    pass
        except EOFError:
            pass
        except Exception:
            record_exception()
开发者ID:goodcrypto,项目名称:goodcrypto-mail,代码行数:70,代码来源:__main__.py


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