Skip to content

Commit da511eb

Browse files
committed
Add basic validate check function
1 parent 0925b39 commit da511eb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/techui_builder/validator.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
import logging
2-
from dataclasses import dataclass
2+
from dataclasses import dataclass, field
33
from pathlib import Path
44

5+
from lxml import etree
6+
57
LOGGER = logging.getLogger(__name__)
68

79

810
@dataclass
911
class 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

0 commit comments

Comments
 (0)