parameters: (directory)
docstring: Remove all possible directories and files from a given directory.
docstring_summary: Remove all possible directories and files from a given directory.
docstring_tokens: Remove all possible directories and files from a given directory .
function: def clear_directory(directory):
      """
      Remove all possible directories and files from a given directory.
      """
      try:
          for path in os.listdir(directory):
              subdirectory = os.path.join(directory, path)
              if os.path.isdir(subdirectory):
                  clear_directory(subdirectory)
              else:
                  os.unlink(subdirectory)
          os.rmdir(directory)
      except OSError:
          if os.path.exists(directory):
              log.info("Failed to clear tmp directory", exc_info=True)
function_tokens: def clear_directory ( directory ) : try : for path in os . listdir ( directory ) : subdirectory = os . path . join ( directory , path ) if os . path . isdir ( subdirectory ) : clear_directory ( subdirectory ) else : os . unlink ( subdirectory ) os . rmdir ( directory ) except OSError : if os . path . exists ( directory ) : log . info ( "Failed to clear tmp directory" , exc_info = True )