(name, props, project_shortname, prefix)
| 177 | |
| 178 | # pylint: disable=R0914 |
| 179 | def generate_class_string(name, props, project_shortname, prefix): |
| 180 | # Here we convert from snake case to camel case |
| 181 | package_name = snake_case_to_camel_case(project_shortname) |
| 182 | |
| 183 | # Ensure props are ordered with children first |
| 184 | props = reorder_props(props=props) |
| 185 | |
| 186 | prop_keys = list(props.keys()) |
| 187 | |
| 188 | wildcards = "" |
| 189 | wildcard_declaration = "" |
| 190 | wildcard_names = "" |
| 191 | default_paramtext = "" |
| 192 | default_argtext = "" |
| 193 | accepted_wildcards = "" |
| 194 | |
| 195 | if any(key.endswith("-*") for key in prop_keys): |
| 196 | accepted_wildcards = get_wildcards_r(prop_keys) |
| 197 | wildcards = ", ..." |
| 198 | wildcard_declaration = wildcard_template.format( |
| 199 | accepted_wildcards.replace("-*", "") |
| 200 | ) |
| 201 | wildcard_names = ", wildcard_names" |
| 202 | |
| 203 | # Produce a string with all property names other than WCs |
| 204 | prop_names = ", ".join( |
| 205 | "'{}'".format(p) for p in prop_keys if "*" not in p and p not in ["setProps"] |
| 206 | ) |
| 207 | |
| 208 | # Filter props to remove those we don't want to expose |
| 209 | for item in prop_keys[:]: |
| 210 | if item.endswith("-*") or item == "setProps": |
| 211 | prop_keys.remove(item) |
| 212 | elif item in r_keywords: |
| 213 | prop_keys.remove(item) |
| 214 | warnings.warn( |
| 215 | ( |
| 216 | 'WARNING: prop "{}" in component "{}" is an R keyword' |
| 217 | " - REMOVED FROM THE R COMPONENT" |
| 218 | ).format(item, name), |
| 219 | stacklevel=2, |
| 220 | ) |
| 221 | |
| 222 | default_argtext += ", ".join("{}=NULL".format(p) for p in prop_keys) |
| 223 | |
| 224 | # pylint: disable=C0301 |
| 225 | default_paramtext += ", ".join( |
| 226 | "{0}={0}".format(p) if p != "children" else "{}=children".format(p) |
| 227 | for p in prop_keys |
| 228 | ) |
| 229 | |
| 230 | return r_component_string.format( |
| 231 | funcname=format_fn_name(prefix, name), |
| 232 | name=name, |
| 233 | default_argtext=default_argtext, |
| 234 | wildcards=wildcards, |
| 235 | wildcard_declaration=wildcard_declaration, |
| 236 | default_paramtext=default_paramtext, |
no test coverage detected
searching dependent graphs…