code: def save(markov, fname, args):
      
      if isinstance(markov.storage, JsonStorage):
          if fname is None:
              markov.save(sys.stdout)
          else:
              if fname.endswith('.bz2'):
                  open_ = bz2.open
              else:
                  open_ = open
              if args.progress:
                  print('Saving JSON data...')
              with open_(fname, 'wt') as fp:
                  markov.save(fp)
      else:
          markov.save()
docs: Save a generator.
  
      Parameters
      ----------
      markov : `markovchain.Markov`
          Generator to save.
      fname : `str`
          Output file path.
      args : `argparse.Namespace`
          Command arguments.