File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 11import logging
2- from dataclasses import dataclass
2+ from dataclasses import dataclass , field
33from pathlib import Path
44
5+ from lxml import etree
6+
57LOGGER = logging .getLogger (__name__ )
68
79
810@dataclass
911class Validator :
1012 path : Path
13+ validate : bool = field (default = False , init = False , repr = False )
14+
15+ def check_bob (self ):
16+ # etree has to used as objectify ignore comments
17+ xml = etree .parse (self .path )
18+ # fetch all the comments at the base of the tree
19+ comments = list (xml .getroot ().itersiblings (tag = etree .Comment , preceding = True ))
20+ if len (comments ) > 0 :
21+ # Check if any comments found are the manually saved tag
22+ if any (str (comment ).startswith ("<!--Saved on " ) for comment in comments ):
23+ self .validate = True
You can’t perform that action at this time.
0 commit comments