'''
Main interface to BSE functionality
'''

from . import io


def get_basis_set(name):
    '''Reads a json basis set file given only the name

    The path to the basis set file is taken to be the 'data' directory
    in this project
    '''

    return io.read_table_basis_by_name(name)


def get_metadata(keys=None, key_filter=None):
    if key_filter:
        raise RuntimeError("key_filter not implemented")

    avail_names = io.get_available_names()

    metadata = {}
    for n in avail_names:
        bs = io.read_table_basis_by_name(n)
        common_name = bs['basisSetName']
        defined_elements = list(bs['basisSetElements'].keys())

        function_types = set()
        for e in bs['basisSetElements'].values():
            for s in e['elementElectronShells']:
                function_types.add(s['shellFunctionType'])

        metadata[common_name] = {
            'mangled_name': n,
            'elements': defined_elements,
            'functiontypes': list(function_types),
        }

    return metadata

'''
Main interface to BSE functionality
'''

from . import io


def get_basis_set(name):
    '''Reads a json basis set file given only the name

    The path to the basis set file is taken to be the 'data' directory
    in this project
    '''

    return io.read_table_basis_by_name(name)


def get_metadata(keys=None, key_filter=None):
    if key_filter:
        raise RuntimeError("key_filter not implemented")

    avail_names = io.get_available_names()

    metadata = {}
    for n in avail_names:
        bs = io.read_table_basis_by_name(n)
        displayname = bs['basisSetName']
        defined_elements = list(bs['basisSetElements'].keys())

        function_types = set()
        for e in bs['basisSetElements'].values():
            for s in e['elementElectronShells']:
                function_types.add(s['shellFunctionType'])

        metadata[n] = {
            'displayname': displayname,
            'elements': defined_elements,
            'functiontypes': list(function_types),
        }

    return metadata

Switch which name is used as a metadata key
Switch which name is used as a metadata key

  '''
  Main interface to BSE functionality
  '''
  
  from . import io
  
  
  def get_basis_set(name):
      '''Reads a json basis set file given only the name
  
      The path to the basis set file is taken to be the 'data' directory
      in this project
      '''
  
      return io.read_table_basis_by_name(name)
  
  
  def get_metadata(keys=None, key_filter=None):
      if key_filter:
          raise RuntimeError("key_filter not implemented")
  
      avail_names = io.get_available_names()
  
      metadata = {}
      for n in avail_names:
          bs = io.read_table_basis_by_name(n)
-         common_name = bs['basisSetName']
+         displayname = bs['basisSetName']
          defined_elements = list(bs['basisSetElements'].keys())
  
          function_types = set()
          for e in bs['basisSetElements'].values():
              for s in e['elementElectronShells']:
                  function_types.add(s['shellFunctionType'])
  
-         metadata[common_name] = {
+         metadata[n] = {
-             'mangled_name': n,
+             'displayname': displayname,
              'elements': defined_elements,
              'functiontypes': list(function_types),
          }
  
      return metadata
  
Switch which name is used as a metadata key
## Code Before:
'''
Main interface to BSE functionality
'''

from . import io


def get_basis_set(name):
    '''Reads a json basis set file given only the name

    The path to the basis set file is taken to be the 'data' directory
    in this project
    '''

    return io.read_table_basis_by_name(name)


def get_metadata(keys=None, key_filter=None):
    if key_filter:
        raise RuntimeError("key_filter not implemented")

    avail_names = io.get_available_names()

    metadata = {}
    for n in avail_names:
        bs = io.read_table_basis_by_name(n)
        common_name = bs['basisSetName']
        defined_elements = list(bs['basisSetElements'].keys())

        function_types = set()
        for e in bs['basisSetElements'].values():
            for s in e['elementElectronShells']:
                function_types.add(s['shellFunctionType'])

        metadata[common_name] = {
            'mangled_name': n,
            'elements': defined_elements,
            'functiontypes': list(function_types),
        }

    return metadata

## Instruction:
Switch which name is used as a metadata key
## Code After:
'''
Main interface to BSE functionality
'''

from . import io


def get_basis_set(name):
    '''Reads a json basis set file given only the name

    The path to the basis set file is taken to be the 'data' directory
    in this project
    '''

    return io.read_table_basis_by_name(name)


def get_metadata(keys=None, key_filter=None):
    if key_filter:
        raise RuntimeError("key_filter not implemented")

    avail_names = io.get_available_names()

    metadata = {}
    for n in avail_names:
        bs = io.read_table_basis_by_name(n)
        displayname = bs['basisSetName']
        defined_elements = list(bs['basisSetElements'].keys())

        function_types = set()
        for e in bs['basisSetElements'].values():
            for s in e['elementElectronShells']:
                function_types.add(s['shellFunctionType'])

        metadata[n] = {
            'displayname': displayname,
            'elements': defined_elements,
            'functiontypes': list(function_types),
        }

    return metadata
