+def export_tg_type_and_version(tg_type=u"unknown", tg_version=u"unknown"):
+ """Export the arguments as tg type and version.
+
+ Robot tends to convert "none" into None, hence the unusual default values.
+
+ If either argument is missing, the value from robot variable is used.
+ If argument is present, the value is also stored to robot suite variable.
+
+ :param tg_type: TG type, e.g. TREX.
+ :param tg_version: TG version as determined by the caller.
+ :type tg_type: Optional[str]
+ :type tg_version: Optiona[str]
+ :raises RuntimeError: If value is neither in argument not robot variable.
+ """
+ if tg_type == u"unknown":
+ tg_type = BuiltIn().get_variable_value(u"\\${TG_TYPE}", u"unknown")
+ if tg_type == u"unknown":
+ raise RuntimeError(u"TG type not provided.")
+ else:
+ # We want to set a variable in higher level suite setup
+ # to be available to test setup several levels lower.
+ BuiltIn().set_suite_variable(
+ u"\\${TG_TYPE}", tg_type, u"children=True"
+ )
+ if tg_version == u"unknown":
+ tg_version = BuiltIn().get_variable_value(
+ u"\\${TG_VERSION}", u"unknown"
+ )
+ if tg_type == u"unknown":
+ raise RuntimeError(u"TG version not provided.")
+ else:
+ BuiltIn().set_suite_variable(
+ u"\\${TG_VERSION}", tg_version, u"children=True"
+ )
+ data = get_export_data()
+ data[u"tg_type"] = tg_type.lower()
+ data[u"tg_version"] = tg_version
+
+