You can filter returns for this report by using one or more of the status detail categories. Is the fact the times are smaller with timieit than with clock() due to the fact that the GC is unplugged when the program is run ? Anyway, with either clock() or timeit module, executing startswith() takes more time than slicing.Fortigate firewall policy not working. Ti = timeit.repeat("x = ('abcdfafdf' = 'end')",repeat=10,number = n) Print '\nMeasuring times with timeit module' Print "\tx = 'abcdfafdf'.startswith('end')" If I would know more about the operations you want to perform with name,value and in the section opened with if line='end', I could propose a code using regexes. The instruction gen_lines = (line.rstrip() for line in f if line.strip())Ĭreates a generator of not empty lines (thanks to the test if line.strip()) without newline and without blanks at the right (thanks to line.rstrip()) # Or if section = open then close and goto end # If subsection = open then close and goto end I would do it in a simpler way: flagSection = False Getattr(Parser, "parse_" method)(self, fields)Ĭonfig = Parser().parse_file('FGT02_nf') Gen_lines = (line.rstrip() for line in f if line.strip()) Return reduce(lambda d, k: d, mapList, dataDict) I rewrote what I found here based on my own needs and it works great. I post my answer for people who first come here from Google when trying to parse Fortigate configuration file !
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |