# Path: gprMax/exceptions.py
# class CmdInputError(ValueError):
#     """Handles errors in user specified commands. Subclasses the ValueError class."""
# 
#     def __init__(self, message, *args):
# 
#         self.message = message
#         super(CmdInputError, self).__init__(message, *args)
#         print(Fore.RED)


import argparse
from gprMax.exceptions import CmdInputError
            # Syntax of old command: #geometry_file: filename
            if params[0].endswith('.geo'):
                params = params[0].split('.')
            replacement = '#geometry_view: 0 0 0 {} {} {} {} {} {} {} n'.format(domain[0], domain[1], domain[2], dx_dy_dz[0], dx_dy_dz[1], dx_dy_dz[2], params[0])
            print("Command '{}', replaced with '{}'. This is a geometry view of the entire domain, sampled at the spatial resolution of the model, using the per Yee cell option (n). You may want to consider taking a smaller geometry view or using a coarser sampling. You may also want to use the per Yee cell edge option (f) to view finer details.".format(inputlines[lindex], replacement))
            inputlines.pop(lindex)
            inputlines.insert(lindex, replacement)
            lindex += 1

        elif cmdname == '#geometry_vtk':
            # Syntax of old command: #geometry_vtk: x1 y1 z1 x2 y2 z2 dx dy dz filename type
            replacement = '#geometry_view: {} {} {} {} {} {} {} {} {} {} {}'.format(params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10])
            print("Command '{}', replaced with '{}'".format(inputlines[lindex], replacement))
            inputlines.pop(lindex)
            inputlines.insert(lindex, replacement)
            lindex += 1

        elif cmdname in ['#plane_wave', '#thin_wire', '#huygens_surface']:
            raise CmdInputError("Command '{}' has not yet implemented in the new version of gprMax. For now please continue to use the old version.".format(inputlines[lindex]))

        else:
            lindex += 1

    else:
        lindex += 1

# Convert separate #line_source and associated #tx to #waveform and #hertzian_dipole
for source in linesources:
    params = source.split()
    if params[3] is badwaveforms:

# Path: gprMax/exceptions.py
# class CmdInputError(ValueError):
#     """Handles errors in user specified commands. Subclasses the ValueError class."""
# 
#     def __init__(self, message, *args):
# 
#         self.message = message
#         super(CmdInputError, self).__init__(message, *args)
#         print(Fore.RED)


# Path: tools/inputfile_old2new.py
import argparse
from gprMax.exceptions import CmdInputError

            # Syntax of old command: #geometry_file: filename
            if params[0].endswith('.geo'):
                params = params[0].split('.')
            replacement = '#geometry_view: 0 0 0 {} {} {} {} {} {} {} n'.format(domain[0], domain[1], domain[2], dx_dy_dz[0], dx_dy_dz[1], dx_dy_dz[2], params[0])
            print("Command '{}', replaced with '{}'. This is a geometry view of the entire domain, sampled at the spatial resolution of the model, using the per Yee cell option (n). You may want to consider taking a smaller geometry view or using a coarser sampling. You may also want to use the per Yee cell edge option (f) to view finer details.".format(inputlines[lindex], replacement))
            inputlines.pop(lindex)
            inputlines.insert(lindex, replacement)
            lindex += 1

        elif cmdname == '#geometry_vtk':
            # Syntax of old command: #geometry_vtk: x1 y1 z1 x2 y2 z2 dx dy dz filename type
            replacement = '#geometry_view: {} {} {} {} {} {} {} {} {} {} {}'.format(params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10])
            print("Command '{}', replaced with '{}'".format(inputlines[lindex], replacement))
            inputlines.pop(lindex)
            inputlines.insert(lindex, replacement)
            lindex += 1

        elif cmdname in ['#plane_wave', '#thin_wire', '#huygens_surface']:
            raise CmdInputError("Command '{}' has not yet implemented in the new version of gprMax. For now please continue to use the old version.".format(inputlines[lindex]))

        else:
            lindex += 1

    else:
        lindex += 1

# Convert separate #line_source and associated #tx to #waveform and #hertzian_dipole
for source in linesources:
    params = source.split()
    if params[3] is badwaveforms:

        raise CmdInputError("Waveform types {} are not compatible between new and old versions of gprMax.".format(''.join(badwaveforms)))