Source code for iwfm.hdf5.print_methods_hdf

# print_methods_hdf.py 
# print dll methods for an hdf file
# Copyright (C) 2018-2024 University of California
# -----------------------------------------------------------------------------
# This information is free; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This work is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# For a copy of the GNU General Public License, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# -----------------------------------------------------------------------------

'''Print dll methods for an hdf file.'''

from iwfm.debug.logger_setup import logger





if __name__ == '__main__':
    '''methods_hdf() from command line '''
    import sys
    import iwfm
    import iwfm.debug as dbg
    from iwfm.debug import parse_cli_flags

    verbose, debug = parse_cli_flags()


    if len(sys.argv) > 1:  # arguments are listed on the command line
        filename = sys.argv[1]
    else:  # ask for file names from terminal
        filename    = input('IWFM HDF file name: ')

    logger.debug(f'{filename=}')

    iwfm.file_test(filename)

    dbg.exe_time()  # initialize timer

    methods = print_methods_hdf(filename, verbose=verbose)

    print(f'  Read {len(methods):,} methods from {filename}.')

    # write methods to text file 
    outfile = filename.split('.')[0] + '_metnods.txt'
    with open(outfile, 'w', encoding='utf-8') as f:
        for method in methods:
            f.write(f'{method}\n')

    dbg.exe_time()  # print elapsed time