예제 #1
0
def main():
    # Initialize logging
    logger = init_log('metadata2html')
    set_log_level(logger, logging.INFO)
    # Convert metadata file
    (configfile, filename, outdir) = parse_arguments()
    if configfile:
        config = import_config(configfile, logger)
        filenames = get_metadata_files_from_config(config, logger)
        outdir = get_output_directory_from_config(config, logger)
        for filename in filenames:
            convert_to_html(filename, outdir, logger)
    else:
        convert_to_html(filename, outdir, logger)
예제 #2
0
import argparse
import sys
import os
import os.path
import logging
# CCPP framework imports
from parse_tools import init_log, set_log_level
from parse_tools import CCPPError, ParseInternalError
from parse_tools import reset_standard_name_counter, unique_standard_name
from fortran_tools import parse_fortran_file
from file_utils import create_file_list
from metadata_table import blank_metadata_line

## Init this now so that all Exceptions can be trapped
_LOGGER = init_log(os.path.basename(__file__))

## Recognized Fortran filename extensions
_FORTRAN_FILENAME_EXTENSIONS = ['F90', 'f90', 'F', 'f']


###############################################################################
def parse_command_line(args, description):
    ###############################################################################
    "Create an ArgumentParser to parse and return command-line arguments"
    parser = argparse.ArgumentParser(
        description=description, formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument("files",
                        metavar='<list of files to process>',
                        type=str,
예제 #3
0
            cap.write(_SUBFOOT.format(host_model=host_model.name,
                                      stage=stage), 1)
        # End for
        # Write the API inspection routines (e.g., list of suites)
        api.write_inspection_routines(cap)
        # Write the constituent initialization interfaces
        err_vars = host_model.find_error_variables()
        const_obj_name = constituent_model_object_name(host_model)
        cap.write("", 0)
        const_names_name = constituent_model_const_stdnames(host_model)
        const_indices_name = constituent_model_const_indices(host_model)
        ConstituentVarDict.write_host_routines(cap, host_model, reg_name,
                                               numconsts_name, copyin_name,
                                               copyout_name, const_obj_name,
                                               const_names_name,
                                               const_indices_name,
                                               api.suites, err_vars)
    # End with
    return cap_filename

###############################################################################

if __name__ == "__main__":
    from parse_tools import init_log, set_log_to_null
    _LOGGER = init_log('host_registry')
    set_log_to_null(_LOGGER)
    # Run doctest
    import doctest
    doctest.testmod()
# No else:
예제 #4
0
    print("Usage:")
    print("{} <source_file> <target_file>".format(cmd))
    print("{} <source_file> [ <source_file> ...] [ <target_directory> ]".format(cmd))
    print("")
    print("Translate the metadata in each <source_file> into a new file")

########################################################################

if __name__ == "__main__":
    # Process the files passed in
    num_args = len(sys.argv)
    if num_args < 3:
        usage(sys.argv[0])
    else:
        ## Init this now so that all Exceptions can be trapped
        logger = init_log('ccpp_capgen')
        set_log_level(logger, logging.INFO)
        ## To cause convert_metadata to stop when an error condition is found
        ## (no metadata file), uncomment out the next line.
        #logger = None
        if os.path.isdir(sys.argv[-1]):
            target_dir = os.path.abspath(sys.argv[-1])
            num_args = num_args - 1
            for index in xrange(1, num_args):
                source_file = os.path.abspath(sys.argv[index])
                filename = os.path.basename(source_file)
                mdfilename = "{}.meta".format('.'.join(filename.split('.')[:-1]))
                dest_file = os.path.join(target_dir, filename)
                dest_mdfile = os.path.join(target_dir, mdfilename)
                convert_file(source_file, dest_file, dest_mdfile, logger)
        else: