
import re as _re
from . import record_names as _record_names


_bend_re = _re.compile('BOMA-B.*')
_qf_re = _re.compile('BOMA-QF.*')
_qd_re = _re.compile('BOMA-QD.*')
_s_re = _re.compile('BOMA-S.*')
_ch_re = _re.compile('BOMA-CH.*')
_cv_re = _re.compile('BOMA-CV.*')


def get_excitation_curve_mapping(accelerator):
    """Get mapping from magnet to excitation curve file names

    Returns dict.
    """
    magnets = _record_names.get_magnet_names(accelerator)

    ec = dict()
    for name in magnets:
        if _bend_re.match(name) is not None: ec[name] = 'boma-bend.txt'
        elif _qf_re.match(name) is not None: ec[name] = 'boma-qf.txt'
        elif _qd_re.match(name) is not None: ec[name] = 'boma-qd.txt'
        elif _s_re.match(name) is not None: ec[name] = 'boma-s.txt'
        elif _ch_re.match(name) is not None: ec[name] = 'boma-ch.txt'
        elif _cv_re.match(name) is not None: ec[name] = 'boma-cv.txt'
        else: ec[name] = 'boma-s.txt'

    return ec

@@ -162,16 +162,17 @@
 D.*')%0A_s
+f
 _re = _r
@@ -188,16 +188,51 @@
 ('BOMA-S
+F.*')%0A_sd_re = _re.compile('BOMA-SD
 .*')%0A_ch
@@ -761,16 +761,17 @@
  elif _s
+f
 _re.matc
@@ -805,24 +805,95 @@
 e%5D = 'boma-s
+f.txt'%0A        elif _sd_re.match(name) is not None: ec%5Bname%5D = 'boma-sd
 .txt'%0A      
@@ -1033,16 +1033,18 @@
 %0A       
+ #
  else: e

Update BO excitation curve names