se adiciona archivo faltante de nomina, y se agregan mas deducciones

FossilOrigin-Name: afb6c19bd3d7f71dd3ceff6e95cc39aaf65d15707eef8535d092e68b34c05c65
This commit is contained in:
bit4bit
2021-11-05 02:09:21 +00:00
parent 3ef002e137
commit 74d98e249d
4 changed files with 173 additions and 5 deletions

View File

@@ -117,8 +117,12 @@ class LXMLBuilder:
def set_attribute(self, elem, key, value):
elem.attrib[key] = value
def remove_attributes(self, elem, keys):
@classmethod
def remove_attributes(cls, elem, keys, exclude = []):
for key in keys:
if key in exclude:
continue
try:
del elem.attrib[key]
except KeyError:
@@ -132,10 +136,8 @@ class LXMLBuilder:
attrs['encoding'] = attrs.pop('encoding', 'UTF-8')
for el in elem.getiterator():
try:
del el.attrib['facho_placeholder']
except KeyError:
pass
keys = filter(lambda key: key.startswith('facho_'), el.keys())
self.remove_attributes(el, keys, exclude=['facho_optional'])
is_optional = el.get('facho_optional', 'False') == 'True'
if is_optional and el.getchildren() == [] and el.keys() == ['facho_optional']:
@@ -364,6 +366,20 @@ class FachoXML:
text = self.builder.get_text(elem)
return format_(text)
def exist_element(self, xpath):
elem = self.get_element(xpath)
if elem is None:
return False
if elem.get('facho_placeholder') == 'True':
return False
if elem.get('facho_optional') == 'True':
return False
return True
def _remove_facho_attributes(self, elem):
self.builder.remove_attributes(elem, ['facho_optional', 'facho_placeholder'])