#   You should have received a copy of the GNU Affero General Public
#   License along with semicontrol.  If not, see
#   <http://www.gnu.org/licenses/>.
#
#######################################################################

# std lib imports
import os.path

# third party imports

# local imports
from simplepl.simple_pl_parser import SimplePLParser
from simplepl.utils import open_dialog, open_multiple_dialog, dir_dialog
print 'Select files from which to remove the system response...'
filenames = open_multiple_dialog('*.*')
print filenames
print 'Select the system response file to open...'
sysres_filename = open_dialog('*.*')
print sysres_filename
print 'Select the directory in which to save the system response removed files...'
sysresrem_dir = dir_dialog()
print sysresrem_dir

for filename in filenames:
    parser = SimplePLParser(filename, sysres_filename)
    parser.parse()
    path, pathless_filename = os.path.split(filename)
    sysresrem_filename = os.path.join(sysresrem_dir, pathless_filename)
    with open(sysresrem_filename, 'w') as f:
        f.write('Wavelength\tSysResRem\n')
#   License along with semicontrol.  If not, see
#   <http://www.gnu.org/licenses/>.
#
#######################################################################
vertical_spacing = 1./2

# std lib imports
import os.path

# third party imports

# local imports
from simplepl.simple_pl_parser import SimplePLParser
from simplepl.utils import open_dialog, open_multiple_dialog, save_dialog
print 'Select the PL files to import...'
pl_filepaths = open_multiple_dialog('*.*')
if not pl_filepaths:
    raise ValueError('no PL files selected')
print pl_filepaths
print 'Select the system response file to use (if any)...'
sysres_filepath = open_dialog('*.*')
print sysres_filepath
print 'Select where to save the vsz file...'
save_filepath = save_dialog('*.*')
if not save_filepath:
    raise ValueError('no save path selected')
if not save_filepath.endswith('.vsz'):
    save_filepath += '.vsz'
print save_filepath

# tokenize the filenames