from docopt import docopt
import sys

import internetarchive



# main()
#_________________________________________________________________________________________
def main(argv):
    args = docopt(__doc__, argv=argv)

    params = dict(p.split(':') for p in args['--parameters'])
    if args['--sort']:
        for i, field in enumerate(args['--sort']):
            key = 'sort[{0}]'.format(i)
            params[key] = field.strip().replace(':', ' ')

    fields = ['identifier'] + args['--field']

    query = ' '.join(args['<query>'])
    search = internetarchive.Search(query, fields=fields, params=params)
    for result in search.results:
        output = '\t'.join([result[f] for f in fields]).encode('utf-8')
        sys.stdout.write(output + '\n')
    sys.exit(0)

from docopt import docopt
import sys

from internetarchive import search



# main()
#_________________________________________________________________________________________
def main(argv):
    args = docopt(__doc__, argv=argv)

    params = dict(p.split(':') for p in args['--parameters'])
    if args['--sort']:
        for i, field in enumerate(args['--sort']):
            key = 'sort[{0}]'.format(i)
            params[key] = field.strip().replace(':', ' ')

    fields = ['identifier'] + args['--field']

    query = ' '.join(args['<query>'])
    search_resp = search(query, fields=fields, params=params)
    for result in search_resp.results():
        output = '\t'.join([result[f] for f in fields]).encode('utf-8')
        sys.stdout.write(output + '\n')
    sys.exit(0)

Use `internetarchive.search()` function rather than `internetarchive.Search` class.
Use `internetarchive.search()` function rather than `internetarchive.Search` class.

  from docopt import docopt
  import sys
  
- import internetarchive
+ from internetarchive import search
  
  
  
  # main()
  #_________________________________________________________________________________________
  def main(argv):
      args = docopt(__doc__, argv=argv)
  
      params = dict(p.split(':') for p in args['--parameters'])
      if args['--sort']:
          for i, field in enumerate(args['--sort']):
              key = 'sort[{0}]'.format(i)
              params[key] = field.strip().replace(':', ' ')
  
      fields = ['identifier'] + args['--field']
  
      query = ' '.join(args['<query>'])
-     search = internetarchive.Search(query, fields=fields, params=params)
+     search_resp = search(query, fields=fields, params=params)
-     for result in search.results:
+     for result in search_resp.results():
          output = '\t'.join([result[f] for f in fields]).encode('utf-8')
          sys.stdout.write(output + '\n')
      sys.exit(0)
  
Use `internetarchive.search()` function rather than `internetarchive.Search` class.
## Code Before:
from docopt import docopt
import sys

import internetarchive



# main()
#_________________________________________________________________________________________
def main(argv):
    args = docopt(__doc__, argv=argv)

    params = dict(p.split(':') for p in args['--parameters'])
    if args['--sort']:
        for i, field in enumerate(args['--sort']):
            key = 'sort[{0}]'.format(i)
            params[key] = field.strip().replace(':', ' ')

    fields = ['identifier'] + args['--field']

    query = ' '.join(args['<query>'])
    search = internetarchive.Search(query, fields=fields, params=params)
    for result in search.results:
        output = '\t'.join([result[f] for f in fields]).encode('utf-8')
        sys.stdout.write(output + '\n')
    sys.exit(0)

## Instruction:
Use `internetarchive.search()` function rather than `internetarchive.Search` class.
## Code After:
from docopt import docopt
import sys

from internetarchive import search



# main()
#_________________________________________________________________________________________
def main(argv):
    args = docopt(__doc__, argv=argv)

    params = dict(p.split(':') for p in args['--parameters'])
    if args['--sort']:
        for i, field in enumerate(args['--sort']):
            key = 'sort[{0}]'.format(i)
            params[key] = field.strip().replace(':', ' ')

    fields = ['identifier'] + args['--field']

    query = ' '.join(args['<query>'])
    search_resp = search(query, fields=fields, params=params)
    for result in search_resp.results():
        output = '\t'.join([result[f] for f in fields]).encode('utf-8')
        sys.stdout.write(output + '\n')
    sys.exit(0)
