comparison cutils/treesum.py @ 378:32b937a73068

treesum: Rename PATTERN0 to PATTERNE
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 12 May 2025 09:48:23 +0200
parents 6b327893a9c3
children 6d7659a709f2
comparison
equal deleted inserted replaced
377:6b327893a9c3 378:32b937a73068
1692 Supports the iterator and context manager protocol. 1692 Supports the iterator and context manager protocol.
1693 1693
1694 """ 1694 """
1695 1695
1696 PATTERNC = re.compile(br"\A\s*[#;].*\r?\n\Z") # comments, no CRC 1696 PATTERNC = re.compile(br"\A\s*[#;].*\r?\n\Z") # comments, no CRC
1697 PATTERN0 = re.compile(br"\A[ \t]*\r?\n\Z") # empty lines 1697 PATTERNE = re.compile(br"\A[ \t]*\r?\n\Z") # empty lines
1698 PATTERN1 = re.compile(br"\A(VERSION|FSENCODING|FLAGS|TIMESTAMP|ISOTIMESTAMP|CRC32)[ \t]*=[ \t]*([^ \t]+)[ \t]*\r?\n\Z") # noqa: E501 line too long 1698 PATTERN1 = re.compile(br"\A(VERSION|FSENCODING|FLAGS|TIMESTAMP|ISOTIMESTAMP|CRC32)[ \t]*=[ \t]*([^ \t]+)[ \t]*\r?\n\Z") # noqa: E501 line too long
1699 PATTERN2 = re.compile(br"\A(ROOT|COMMENT|ERROR|GENERATOR|FNMATCH|ACCEPT-TREESUM)[ \t]*\((.*)\)[ \t]*\r?\n\Z") # noqa: E501 line too long 1699 PATTERN2 = re.compile(br"\A(ROOT|COMMENT|ERROR|GENERATOR|FNMATCH|ACCEPT-TREESUM)[ \t]*\((.*)\)[ \t]*\r?\n\Z") # noqa: E501 line too long
1700 PATTERN3 = re.compile(br"\ASIZE[ \t]*\((.*)\)([ \t]*=[ \t]*([0-9., '_]*[0-9]))?[ \t]*\r?\n\Z") # noqa: E501 line too long 1700 PATTERN3 = re.compile(br"\ASIZE[ \t]*\((.*)\)([ \t]*=[ \t]*([0-9., '_]*[0-9]))?[ \t]*\r?\n\Z") # noqa: E501 line too long
1701 PATTERN4 = re.compile(br"\A([A-Za-z0-9_-]+)[ \t]*\((.*)\)([ \t]*=[ \t]*([A-Za-z0-9=+/]+)?(,([0-9., '_]*[0-9])?)?)?[ \t]*\r?\n\Z") # noqa: E501 line too long 1701 PATTERN4 = re.compile(br"\A([A-Za-z0-9_-]+)[ \t]*\((.*)\)([ \t]*=[ \t]*([A-Za-z0-9=+/]+)?(,([0-9., '_]*[0-9])?)?)?[ \t]*\r?\n\Z") # noqa: E501 line too long
1702 1702
1776 logging.warning("CRC32 is missing at EOF") 1776 logging.warning("CRC32 is missing at EOF")
1777 return None 1777 return None
1778 # Skip comments and do NOT update CRC for comment lines 1778 # Skip comments and do NOT update CRC for comment lines
1779 if self.PATTERNC.search(line): 1779 if self.PATTERNC.search(line):
1780 continue 1780 continue
1781 if not self.PATTERN0.search(line): 1781 if not self.PATTERNE.search(line):
1782 break 1782 break
1783 # Empty lines count for CRC 1783 # Empty lines count for CRC
1784 self._update_crc(line) 1784 self._update_crc(line)
1785 # 1785 #
1786 # At the beginning transparently skip an eventually embedded signify 1786 # At the beginning transparently skip an eventually embedded signify