def compute_config(rescan, bypass):
    """
    Update the configuration with the information needed by compileTELEMAC

    @param cfgname (string) Name of the configuration
    @param options (ArgumentParser) Options of the script
    """
    CFGS.compute_compilation_info(\
                    rescan=rescan,
                    bypass=bypass)
Ejemplo n.º 2
0
def compute_config(rescan, bypass):
    """
    Update the configuration with the information needed by compileTELEMAC

    @param rescan (boolean) If true run rescan
    @param bypass (boolean) If True bypass error
    """
    CFGS.compute_compilation_info(\
                    rescan=rescan,
                    bypass=bypass)
def main():
    """ Main function of parserDELWAQ """

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + '~' * 72 + '\n')
    parser = ArgumentParser(\
        formatter_class=RawDescriptionHelpFormatter,
        description=('''\n\
Tools for handling DELWAQ files when created by TELEMAC
        '''),
        usage=' (--help for help)\n---------\n       =>  '\
                '%(prog)s [option] delwaq.cas \n---------')
    parser = add_config_argument(parser)
    parser.add_argument(\
        "--reset", action="store_true",
        dest="areset", default=False,
        help="reset the start time to zero")
    parser.add_argument(\
        "--minvol",
        dest="minvol", default='0.001',
        help="make sure there is a minimum volume")
    parser.add_argument(\
        "--from",
        dest="tfrom", default="1",
        help="specify the first frame included")
    parser.add_argument(\
        "--stop",
        dest="tstop", default="-1",
        help="specify the last frame included (negative from the end)")
    parser.add_argument("args", nargs="+")
    options = parser.parse_args()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Works for only one configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update_config(options)
    CFGS.compute_compilation_info()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Reads command line arguments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if len(options.args) < 1:
        print('\nAt least one DELWAQ steering file name is required\n')
        parser.print_help()
        raise Exception
    file_names = options.args

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Loop over the DELWAQ files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    for fle in file_names:

        # ~~> Parse DELWAQ steering file
        print('      ~> scanning your DELWAQ file: ' + path.basename(fle))
        dwq = DELWAQ(fle)

        # ~~> Possible options so far
        if options.areset:
            dwq.reset_dwq()
        dwq.minvol_dwq(options.minvol)
        dwq.sample_dwq(options.tfrom, options.tstop)

        # ~~> Convert to Little Endian
        dwq.big2little()


# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Jenkins' success message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nMy work is done\n\n')

    sys.exit(0)