-
Notifications
You must be signed in to change notification settings - Fork 66
First version of metadata2html converter #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9830424
scripts/metavar.py: intent and optional are only for scheme variables…
climbfuji 6c26eae
scripts/metadata_table.py, scripts/metadata2html.py: recording develo…
climbfuji b3c96ec
scripts/metadata_table.py, scripts/metadata2html.py: initial working …
climbfuji eec1321
scripts/metadata_table.py, scripts/metadata2html.py: write html files…
climbfuji 577ffaf
scripts/convert_metadata*.py: don't add htmlinclude statement for bla…
climbfuji 844fed0
scripts/metadata_table.py: replace dummy title with name of argument …
climbfuji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| import argparse | ||
| import logging | ||
| import os | ||
| import sys | ||
|
|
||
| # CCPP framework imports | ||
| from parse_tools import init_log, set_log_level | ||
| from metadata_table import MetadataHeader | ||
|
|
||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument('--metafile', '-m', action='store', | ||
| help='name of metadata file to convert', | ||
| required=True) | ||
| parser.add_argument('--outputdir', '-o', action='store', | ||
| help='directory where to write the html files', | ||
| required=True) | ||
|
|
||
| attributes = [ 'standard_name', 'long_name', 'units', 'local_name', | ||
| 'type', 'dimensions', 'kind', 'intent', 'optional' ] | ||
|
|
||
| def parse_arguments(): | ||
| """Parse command line arguments.""" | ||
| args = parser.parse_args() | ||
| filename = args.metafile | ||
| outdir = args.outputdir | ||
| return (filename, outdir) | ||
|
|
||
| def convert_to_html(filename_in, outdir, logger): | ||
| """Convert a metadata file into html (one html file for each table)""" | ||
| if not os.path.isfile(filename_in): | ||
| raise Exception("Metadata file {} not found".format(filename_in)) | ||
| logger.info("Converting file {} to HTML".format(filename_in)) | ||
| metadata_headers = MetadataHeader.parse_metadata_file(filename_in) | ||
| for metadata_header in metadata_headers: | ||
| filename_out = metadata_header.to_html(outdir, attributes) | ||
| if filename_out: | ||
| logger.info(" ... wrote {}".format(filename_out)) | ||
|
|
||
| def main(): | ||
| # Initialize logging | ||
| logger = init_log('metadata2html') | ||
| set_log_level(logger, logging.INFO) | ||
| # Convert metadata file | ||
| (filename, outdir) = parse_arguments() | ||
| convert_to_html(filename, outdir, logger) | ||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which attributes should be displayed? I would argue not all of them in the scientific documentation. Maybe just standard_name, long_name, and units (intent might be useful too)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Something we need to iterate on with Ligia, Julie and Man as well. This script is a first version and I was hoping to improve it with the coming metadata conversions.