def test_unique(self): """unique""" self.assertEqual(Utils.unique(range(5)), range(5)) self.assertEqual(Utils.unique([1, 1, 2, 2, 3]), [1, 2, 3]) self.assertEqual(Utils.unique([1, 1, 3, 2, 2, 3]), [1, 3, 2])
raise (ValueError("No mission in DB, this must be an empty db")) if len(missions) > 1: raise (NotImplementedError("Can't yet handle multi mission db")) mission = missions[0] mission = dbu.getEntry('Mission', mission) for d in dir(mission): if d[0] == '_': continue out.set('mission', d, str(getattr(mission, d))) # get satellite out.add_section('satellite') sats = dbu.getAllSatellites() for v in sats: if v['mission'].mission_id != mission.mission_id: raise (NotImplementedError("Can't yet handle multi mission db")) nsats = len(Utils.unique([v['satellite'].satellite_id for v in sats])) if nsats > 1 and options.satellite is None: raise (ValueError("More than one sat in db and no --satellite set\n {0}".format( [v['satellite'].satellite_name for v in sats]))) elif nsats == 1 and options.satellite is None: options.satellite = sats['satellite'].satellite_name for s in sats: if s['satellite'].satellite_name != options.satellite: continue for d in dir(s['satellite']): if d[0] == '_': continue out.set('satellite', d, str(getattr(s['satellite'], d))) # get instrument out.add_section('instrument') insts = dbu.getAllInstruments()