• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / RestrictedPython / 16550884845

20 Mar 2025 07:39AM UTC coverage: 98.772%. Remained the same
16550884845

push

github

icemac
Back to development: 8.1

213 of 231 branches covered (92.21%)

2493 of 2524 relevant lines covered (98.77%)

0.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/RestrictedPython/PrintCollector.py
1
##############################################################################
2
#
3
# Copyright (c) 2002 Zope Foundation and Contributors.
4
#
5
# This software is subject to the provisions of the Zope Public License,
6
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
7
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10
# FOR A PARTICULAR PURPOSE
11
#
12
##############################################################################
13

14

15
class PrintCollector:
1✔
16
    """Collect written text, and return it when called."""
17

18
    def __init__(self, _getattr_=None):
1✔
19
        self.txt = []
1✔
20
        self._getattr_ = _getattr_
1✔
21

22
    def write(self, text):
1✔
23
        self.txt.append(text)
1✔
24

25
    def __call__(self):
1✔
26
        return ''.join(self.txt)
1✔
27

28
    def _call_print(self, *objects, **kwargs):
1✔
29
        if kwargs.get('file', None) is None:
1✔
30
            kwargs['file'] = self
1✔
31
        else:
32
            self._getattr_(kwargs['file'], 'write')
1✔
33

34
        print(*objects, **kwargs)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc