mardi 21 février 2017

How to organize growing number of regular expression strings

I am new to Python. Am writing a small test-suite in python that tests underlying OS module through command-line. I use those commands to perform operations on the OS-module-objects and parse the stdout/stderr outputs to decide on pass or fail. I have some 1500 lines of code but am already having some 50 regular expressions. This is expected to grow. How can I handle these regular expression strings?

Currently I have a dedicated class per underlying module object. Regular expressions to parse the output of command on respective object is declared as series of global variables in respective file. However as commands are added and objects are added, total number of regular expressions is going to increase exponentially. How should I maintain them. As it is now? Or have a separate file and define them there. Don't see any obvious advantage or disadvantage in either. Any pointers/suggestions will help.

Aucun commentaire:

Enregistrer un commentaire