#!/usr/bin/env python
from __future__ import print_function, division, unicode_literals

"""
Script to edit DSUP files to allow user FITS headers.

Enabling user FITS headers is a two step process.

1) Edit DSUP files and install custom dictionary

Run this script to update the DSUP files to contain header items and default values
defined below. The script will also install a custom dictionary defining the FITS header
keywords into /introot/{user}/config.

2) Recompile the IR software.

Either run the irRebuild.sh script or,

cd ~/hipircfg/src
make install
"""
import os
import shutil
import pkg_resources
import getpass


def install_dictionary():
    dictionary_file = pkg_resources.resource_filename('hcam_drivers',
                                                      'data/ESO-VLT-DIC.HIPUSR')
    install_dir = '/introot/{}/config/'.format(getpass.getuser())
    install_path = os.path.join(install_dir, 'ESO-VLT-DIC.HIPUSR')
    shutil.copy(dictionary_file, install_path)


if __name__ == "__main__":
    install_dictionary()
    print('S/W patched - please run irRebuild.sh')