""" line_len - checker for vxnorm This file does not expose an explicite VxChecker object declaration to avoid dependencies handling, you just need to provide: ======================= =============================================== parse_file() Parse the source file ======================= =============================================== """ #--- # Public #--- def parse_file(checker, mfile, _): """ parse the mapped file The file is mapped using mmap() and seeked through offset 0 to avoid too many I/O operations with classical file primitive. @args > checker (VxChecker) - current checker instance for this file > mfile (mmap) - mmap instance of the file, seeked at 0 > pathname (str) - file pathname @return > Nothing """ counter = 0 checker.select_rule('linelen') for line in mfile.getlines(): counter += 1 if len(line) <= 80 or line[0] == '#': continue checker.notify(f"{counter}", f"too long line ({len(line)}/80)")