Simplified implementation of the same interface as py.log, for backward compatibility since we dropped the dependency on pylib. Note: this is defined here because this module can't depend on xdist, so we need to have the other way around.
| 37 | |
| 38 | |
| 39 | class Producer: |
| 40 | """ |
| 41 | Simplified implementation of the same interface as py.log, for backward compatibility |
| 42 | since we dropped the dependency on pylib. |
| 43 | Note: this is defined here because this module can't depend on xdist, so we need |
| 44 | to have the other way around. |
| 45 | """ |
| 46 | |
| 47 | def __init__(self, name: str, *, enabled: bool = True) -> None: |
| 48 | self.name = name |
| 49 | self.enabled = enabled |
| 50 | |
| 51 | def __repr__(self) -> str: |
| 52 | return f"{type(self).__name__}({self.name!r}, enabled={self.enabled})" |
| 53 | |
| 54 | def __call__(self, *a: Any, **k: Any) -> None: |
| 55 | if self.enabled: |
| 56 | print(f"[{self.name}]", *a, **k, file=sys.stderr) |
| 57 | |
| 58 | def __getattr__(self, name: str) -> Producer: |
| 59 | return type(self)(name, enabled=self.enabled) |
| 60 | |
| 61 | |
| 62 | def worker_title(title: str) -> None: |
no outgoing calls
no test coverage detected
searching dependent graphs…