88
99matrix_group_count = {}
1010
11+
1112def clean_header (header ):
1213 cleaned_header = {}
1314 for k , v in header .items ():
1415 # Strip BOM, whitespace, and enclosing quotation marks if present
15- cleaned_key = k .lstrip (' \ufeff ' ).strip ().strip ('"' )
16+ cleaned_key = k .lstrip (" \ufeff " ).strip ().strip ('"' )
1617 cleaned_header [cleaned_key ] = v
1718 return cleaned_header
1819
@@ -24,24 +25,28 @@ def normalize_condition(condition_str):
2425 re_brackets = re .compile (r"\[([^\]]*)\]" )
2526 re_extra_spaces = re .compile (r"\s+" )
2627 re_double_quotes = re .compile (r'"' )
27- re_or = re .compile (r' \bor\b' ) # Match 'or' as whole word
28+ re_or = re .compile (r" \bor\b" ) # Match 'or' as whole word
2829
2930 # Apply regex replacements
3031 condition_str = re_parentheses .sub (r"___\1" , condition_str )
3132 condition_str = re_non_gt_lt_equal .sub (r"\1 ==" , condition_str )
3233 condition_str = re_brackets .sub (r" \1 " , condition_str )
3334
3435 # Replace 'or' with '||', ensuring not to replace '||'
35- condition_str = re_or .sub ('||' , condition_str )
36+ condition_str = re_or .sub ("||" , condition_str )
3637
3738 # Replace 'and' with '&&'
3839 condition_str = condition_str .replace (" and " , " && " )
3940
4041 # Trim extra spaces and replace double quotes with single quotes
41- condition_str = re_extra_spaces .sub (' ' , condition_str ).strip () # Reduce multiple spaces to a single space
42- condition_str = re_double_quotes .sub ("'" , condition_str ) # Replace double quotes with single quotes
42+ condition_str = re_extra_spaces .sub (
43+ " " , condition_str
44+ ).strip () # Reduce multiple spaces to a single space
45+ condition_str = re_double_quotes .sub (
46+ "'" , condition_str
47+ ) # Replace double quotes with single quotes
4348
44- return condition_str .strip ()
49+ return condition_str .strip ()
4550
4651
4752def process_visibility (data ):
@@ -116,7 +121,7 @@ def process_choices(field_type, choices_str):
116121 value = parts [0 ]
117122
118123 choice_obj = {"name" : " " .join (parts [1 :]), "value" : value }
119- # remove image for now
124+ # remove image for now
120125 # if len(parts) == 3:
121126 # # Handle image url
122127 # choice_obj["image"] = f"{parts[2]}.png"
@@ -204,10 +209,7 @@ def process_row(
204209 }
205210
206211 for key , value in field .items ():
207- if (
208- schema_map .get (key ) in ["question" , "description" , "preamble" ]
209- and value
210- ):
212+ if schema_map .get (key ) in ["question" , "description" , "preamble" ] and value :
211213 rowData .update ({schema_map [key ]: parse_html (value )})
212214
213215 elif schema_map .get (key ) == "allow" and value :
@@ -349,7 +351,9 @@ def create_protocol_schema(
349351 "variableName" : f"{ activity } _schema" ,
350352 # Assuming activity name as prefLabel, update as needed
351353 "prefLabel" : activity .replace ("_" , " " ).title (),
352- "isVis" : protocol_visibility_obj .get (activity , True ), # Default to True if not specified
354+ "isVis" : protocol_visibility_obj .get (
355+ activity , True
356+ ), # Default to True if not specified
353357 }
354358 protocol_schema ["ui" ]["addProperties" ].append (add_property )
355359 # Add the full path to the order list
0 commit comments