code: def refactor(self, items, write=False, doctests_only=False):
          
  
          for dir_or_file in items:
              if os.path.isdir(dir_or_file):
                  self.refactor_dir(dir_or_file, write, doctests_only)
              else:
                  self.refactor_file(dir_or_file, write, doctests_only)
docs: Refactor a list of files and directories.