code: def mute(returns_output=False):
      """Decorate a function that prints to stdout, intercepting the output.
      If "returns_output" is True, the function will return a generator
      yielding the printed lines instead of the return values.
  
      The decorator literally hijack sys.stdout during each function
      execution, so be careful with what you apply it to.
  
      >>> def numbers():
          print "42"
          print "1984"
      ...
      >>> numbers()
      42
      1984
      >>> mute()(numbers)()
      >>> list(mute(True)(numbers)())
      ['42', '1984']
  
      """
  
      def decorator(func):
          @wraps(func)
          def wrapper(*args, **kwargs):
              saved_stdout = sys.stdout
              sys.stdout = StringIO()
  
              try:
                  out = func(*args, **kwargs)
                  if returns_output:
                      out = isplit(sys.stdout.getvalue().strip())
              finally:
                  sys.stdout = saved_stdout
  
              return out
  
          return wrapper
  
      return decorator
  
imports: import locale
  import logging
  import os
  import re
  import subprocess
  import sys
  import unittest
  from contextlib import contextmanager
  from functools import wraps
  from io import StringIO
  from logging.handlers import BufferingHandler
  from shutil import rmtree
  from tempfile import mkdtemp
  from pelican.contents import Article
  from pelican.readers import default_metadata
  from pelican.settings import DEFAULT_CONFIG
label_desc: Use image node_id 3 for calling a global function with example usage: mute(returns_output) and returns: decorator, wrapper, out