Skip to content
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

Unify setup_expt.py and setup_expt_fcstonly.py #537

Merged
merged 12 commits into from
Feb 3, 2022
48 changes: 42 additions & 6 deletions ush/rocoto/rocoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@

ABOUT:
Helper module to create tasks, metatasks, and dependencies

AUTHOR:
Rahul.Mahajan
rahul.mahajan@noaa.gov
Brian Curtis (2021): Port to python 3.6.3+
brian.curtis@noaa.gov
'''

def create_metatask(task_dict, metatask_dict):
Expand Down Expand Up @@ -341,3 +335,45 @@ def create_envar(name=None,value=None):
string += '</envar>'

return string


def create_cycledef(group=None, start=None, stop=None, step=None):
'''
create an Rocoto cycle definition
returns the environment variable as a string
:param group: cycle definition group name
:type group: str
:param start: cycle start datetime
:type start: str
:param end: cycle end datetime
:type stop: str
:param step: cycle interval (timedelta)
:type interval: str
:param value: value of the environment variable
:type value: str or float or int or unicode
:return: Rocoto cycledef variable string
:rtype: str
'''

string = ''
string += f'<cycledef group="{group}">'
string += f'{start} {stop} {step}'
string += '</cycledef>'

return string


def create_entity(name=None, value=None):
'''
create an XML ENTITY variable given name and value
returns the variable as a string
:param name: name of the variable
:type name: str
:param value: value of the variable
:type value: str or float or int or unicode
:return: XML entity variable key-value pair
:rtype: str
'''

return f'<!ENTITY {name} "{value}">'

Loading