docs: def get_filename4code(module, content, ext=None):
      """Generate filename based on content
  
      The function ensures that the (temporary) directory exists, so that the
      file can be written.
  
      Example:
          filename = get_filename4code("myfilter", code)
      """
      imagedir = module + "-images"
      fn = hashlib.sha1(content.encode(sys.getfilesystemencoding())).hexdigest()
      try:
          os.mkdir(imagedir)
          sys.stderr.write('Created directory ' + imagedir + '\n')
      except OSError:
          pass
      if ext:
          fn += "." + ext
      return os.path.join(imagedir, fn)