File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change 1111
1212from robot .api import get_model
1313from robot .api .parsing import Variable , VariableSection
14+ from robot .running import ResourceFileBuilder
1415
1516# Define paths
1617BASE_DIR = "platform-configs" # Adjust this if needed
2021
2122def get_defined_variables (file_path ):
2223 """Extract variable names from a Robot Framework file using RF parser."""
23- with open (file_path , encoding = "utf-8" ) as f :
24- model = get_model (f .read ())
25-
26- variables = set ()
27- for section in model .sections :
28- if isinstance (section , VariableSection ):
29- for var in section .body :
30- if isinstance (var , Variable ):
31- variables .add (var .name )
24+ variables = ResourceFileBuilder ().build (file_path ).variables
25+ variables = set ([var .name for var in variables ])
3226 return variables
3327
3428
You can’t perform that action at this time.
0 commit comments