docs: def importdb(indir):
      """Import a previously exported anchore DB"""
      ecode = 0
      try:
          imgdir = os.path.join(indir, "images")
          feeddir = os.path.join(indir, "feeds")
          storedir = os.path.join(indir, "storedfiles")
  
          for d in [indir, imgdir, feeddir, storedir]:
              if not os.path.exists(d):
                  raise Exception ("specified directory "+str(indir)+" does not appear to be complete (missing "+str(d)+")")
  
                  
          anchore_print("importing images...")
          #imagelist = []
          for ifile in os.listdir(imgdir):
              patt = re.match("(.*)\.json", ifile)
              if patt:
                  imageId = patt.group(1)
  
                  if contexts['anchore_db'].is_image_present(imageId):
                      anchore_print("\timage ("+str(imageId)+") already exists in DB, skipping import.")
                  else:
                      #imagelist.append(patt.group(1))
                      thefile = os.path.join(imgdir, ifile)
                      with open(thefile, 'r') as FH:
                          imagedata = json.loads(FH.read())
                      try:
                          rc = contexts['anchore_db'].save_image_new(imageId, report=imagedata)
                          if not rc:
                              contexts['anchore_db'].delete_image(imageId)
                              raise Exception("save to anchore DB failed")
                      except Exception as err:
                          contexts['anchore_db'].delete_image(imageId)
                          raise err
  
                      thedir = os.path.join(storedir, imageId)
                      if os.path.exists(thedir):
                          for namespace in os.listdir(thedir):
                              thefile = os.path.join(thedir, namespace, "stored_files.tar.gz")
                              if os.path.exists(thefile):
                                  contexts['anchore_db'].save_files_tarfile(imageId, namespace, thefile)
  
                      anchore_print("\timage ("+str(imageId)+") imported.")
  
          anchore_print("importing feeds...")
          thefile = os.path.join(feeddir, "feedmeta.json")
          with open(thefile, 'r') as FH:
              feedmeta = json.loads(FH.read())
  
          if feedmeta:
              contexts['anchore_db'].save_feedmeta(feedmeta)
  
          for feed in feedmeta:
              feedobj = feedmeta[feed]
              for group in feedobj['groups']:
                  groupobj = feedobj['groups'][group]
                  datafiles = groupobj.pop('datafiles', [])
                  for datafile in datafiles:
                      thedir = os.path.join(feeddir, feed, group)
                      thefile = os.path.join(thedir, datafile)
                      if not os.path.exists(thefile):
                          pass
                      else:
                          with open(thefile, 'r') as FH:
                              contexts['anchore_db'].save_feed_group_data(feed, group, datafile, json.loads(FH.read()))
                      anchore_print("\tfeed ("+feed+" " + group + " " + datafile + ") imported")
  
          #TODO import stored files
  
      except Exception as err:
          anchore_print_err("operation failed: " + str(err))
          ecode = 1
  
      sys.exit(ecode)