Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to create a rule in RuleWizard to check if the filename contains the foldername?

nadine
nadine Posts: 3

I want to create a rule that checks if a filename contains the foldername at the beginning of the file, for example:

I have a folder named "folder1" containing a folder named "folder2" which contains a c file. This file should be named:
"folder1_folder2_myFile.c"

Is it possible to create such a rule with the rule wizard?

Comments

  • mstaron
    mstaron Posts: 33

    Yes, I think it is possible. You can use properties 'filename' and 'pathname' for the 'file' node. If you need to compare modified names, then you can use python method (File->Create Method->Boolean)

  • nadine
    nadine Posts: 3

    Thank you for your answer. It works so far with the python script. Now I wanted to check the filename with a regular expression inside the python script but to do that I need to import the python re module. Is there a way to use python modules in the rule wizard?

  • mstaron
    mstaron Posts: 33

    Yes, it is possible to use 'import re' in python methods in Rule Wizard. The example you can find in built-in rule PB-45 (getValueFromStringColA python method).