Skip to content

Commit

Permalink
#9 Modify data_table_to_yaml.py to be a python module that does not …
Browse files Browse the repository at this point in the history
…run when imported
  • Loading branch information
Chris Blanton authored and Chris Blanton committed Sep 19, 2022
1 parent 6ec397e commit 9f1a5a1
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions fms_yaml_tools/data_table/data_table_to_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@
import argparse
import yaml

#: parse user input
parser = argparse.ArgumentParser(prog='data_table_to_yaml',\
description="Converts a legacy ascii data_table to a yaml data_table. \
Requires pyyaml (https://pyyaml.org/) \
More details on the data_table yaml format can be found in \
https://github.com/NOAA-GFDL/FMS/tree/main/data_override")
parser.add_argument('-f', type=str, help='Name of the data_table file to convert' )
in_data_table = parser.parse_args().f
def main():
#: parse user input
parser = argparse.ArgumentParser(prog='data_table_to_yaml',\
description="Converts a legacy ascii data_table to a yaml data_table. \
Requires pyyaml (https://pyyaml.org/) \
More details on the data_table yaml format can be found in \
https://github.com/NOAA-GFDL/FMS/tree/main/data_override")
parser.add_argument('-f', type=str, help='Name of the data_table file to convert' )
in_data_table = parser.parse_args().f

test_class = DataType(data_table_file=in_data_table)
test_class.convert_data_table()

if __name__ == "__main__":
main()

class DataType :
def __init__(self, data_table_file='data_table') :
Expand Down Expand Up @@ -121,6 +128,3 @@ def convert_data_table(self) :
self.read_and_parse_data_table()
myfile = open(self.data_table_file+'.yaml', 'w')
yaml.dump(self.data_type, myfile, sort_keys=False)

test_class = DataType(data_table_file=in_data_table)
test_class.convert_data_table()

0 comments on commit 9f1a5a1

Please sign in to comment.