# Licensed under a 3-clause BSD style license - see LICENSE.rst
from astropy import log
from ..splatalogue.load_species_table import SpeciesLookuptable


def species_lookuptable():

    log.info("Loading molecular line ID database")

    from vamdclib import nodes
    from vamdclib import request as r

    nl = nodes.Nodelist()
    nl.findnode('cdms')
    cdms = nl.findnode('cdms')

    request = r.Request(node=cdms)

    # Retrieve all species from CDMS
    result = request.getspecies()
    molecules = result.data['Molecules']

    lookuptable = SpeciesLookuptable({molecules[key].OrdinaryStructuralFormula:
                                      molecules[key].VAMDCSpeciesID
                                      for key in molecules})

    return lookuptable

@@ -537,41 +537,96 @@
    l
-ookuptable = SpeciesLookuptable(%7B
+utdict = %7B%22%7B0%7D %7B1%7D%22.format(molecules%5Bkey%5D.ChemicalName,%0A                                
 mole
@@ -665,33 +665,11 @@
 mula
+)
 :%0A
-                       
     
@@ -728,52 +728,74 @@
     
-                       for key in molecules%7D
+for key in molecules%7D%0A    lookuptable = SpeciesLookuptable(lutdict
 )%0A%0A 

fix a minor issue with lut