Python lxml.etree.ElementBase() Examples
The following are 16
code examples of lxml.etree.ElementBase().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
lxml.etree
, or try the search function
.
Example #1
Source File: formfill.py From aws-lambda-lxml with GNU General Public License v3.0 | 6 votes |
def insert_errors( el, errors, form_id=None, form_index=None, error_class="error", error_creator=default_error_creator, ): el = _find_form(el, form_id=form_id, form_index=form_index) for name, error in errors.items(): if error is None: continue for error_el, message in _find_elements_for_name(el, name, error): assert isinstance(message, (basestring, type(None), ElementBase)), ( "Bad message: %r" % message) _insert_error(error_el, message, error_class, error_creator)
Example #2
Source File: formfill.py From aws-lambda-lxml with GNU General Public License v3.0 | 6 votes |
def insert_errors( el, errors, form_id=None, form_index=None, error_class="error", error_creator=default_error_creator, ): el = _find_form(el, form_id=form_id, form_index=form_index) for name, error in errors.items(): if error is None: continue for error_el, message in _find_elements_for_name(el, name, error): assert isinstance(message, (basestring, type(None), ElementBase)), ( "Bad message: %r" % message) _insert_error(error_el, message, error_class, error_creator)
Example #3
Source File: formfill.py From aws-lambda-lxml with GNU General Public License v3.0 | 6 votes |
def insert_errors( el, errors, form_id=None, form_index=None, error_class="error", error_creator=default_error_creator, ): el = _find_form(el, form_id=form_id, form_index=form_index) for name, error in errors.items(): if error is None: continue for error_el, message in _find_elements_for_name(el, name, error): assert isinstance(message, (basestring, type(None), ElementBase)), ( "Bad message: %r" % message) _insert_error(error_el, message, error_class, error_creator)
Example #4
Source File: formfill.py From learn_python3_spider with MIT License | 6 votes |
def insert_errors( el, errors, form_id=None, form_index=None, error_class="error", error_creator=default_error_creator, ): el = _find_form(el, form_id=form_id, form_index=form_index) for name, error in errors.items(): if error is None: continue for error_el, message in _find_elements_for_name(el, name, error): assert isinstance(message, (basestring, type(None), ElementBase)), ( "Bad message: %r" % message) _insert_error(error_el, message, error_class, error_creator)
Example #5
Source File: formfill.py From stopstalk-deployment with MIT License | 6 votes |
def insert_errors( el, errors, form_id=None, form_index=None, error_class="error", error_creator=default_error_creator, ): el = _find_form(el, form_id=form_id, form_index=form_index) for name, error in errors.items(): if error is None: continue for error_el, message in _find_elements_for_name(el, name, error): assert isinstance(message, (basestring, type(None), ElementBase)), ( "Bad message: %r" % message) _insert_error(error_el, message, error_class, error_creator)
Example #6
Source File: formfill.py From lambda-text-extractor with Apache License 2.0 | 6 votes |
def insert_errors( el, errors, form_id=None, form_index=None, error_class="error", error_creator=default_error_creator, ): el = _find_form(el, form_id=form_id, form_index=form_index) for name, error in errors.items(): if error is None: continue for error_el, message in _find_elements_for_name(el, name, error): assert isinstance(message, (basestring, type(None), ElementBase)), ( "Bad message: %r" % message) _insert_error(error_el, message, error_class, error_creator)
Example #7
Source File: formfill.py From lambda-text-extractor with Apache License 2.0 | 6 votes |
def insert_errors( el, errors, form_id=None, form_index=None, error_class="error", error_creator=default_error_creator, ): el = _find_form(el, form_id=form_id, form_index=form_index) for name, error in errors.items(): if error is None: continue for error_el, message in _find_elements_for_name(el, name, error): assert isinstance(message, (basestring, type(None), ElementBase)), ( "Bad message: %r" % message) _insert_error(error_el, message, error_class, error_creator)
Example #8
Source File: formfill.py From aws-lambda-lxml with GNU General Public License v3.0 | 5 votes |
def __call__(self, el, is_block, message): error_el = el.makeelement(self.error_container_tag) if self.error_message_class: error_el.set('class', self.error_message_class) if is_block and self.error_block_class: error_el.set('class', error_el.get('class', '')+' '+self.error_block_class) if message is None or message == '': message = self.default_message if isinstance(message, ElementBase): error_el.append(message) else: assert isinstance(message, basestring), ( "Bad message; should be a string or element: %r" % message) error_el.text = message or self.default_message if is_block and self.block_inside: if self.insert_before: error_el.tail = el.text el.text = None el.insert(0, error_el) else: el.append(error_el) else: parent = el.getparent() pos = parent.index(el) if self.insert_before: parent.insert(pos, error_el) else: error_el.tail = el.tail el.tail = None parent.insert(pos+1, error_el)
Example #9
Source File: formfill.py From aws-lambda-lxml with GNU General Public License v3.0 | 5 votes |
def __call__(self, el, is_block, message): error_el = el.makeelement(self.error_container_tag) if self.error_message_class: error_el.set('class', self.error_message_class) if is_block and self.error_block_class: error_el.set('class', error_el.get('class', '')+' '+self.error_block_class) if message is None or message == '': message = self.default_message if isinstance(message, ElementBase): error_el.append(message) else: assert isinstance(message, basestring), ( "Bad message; should be a string or element: %r" % message) error_el.text = message or self.default_message if is_block and self.block_inside: if self.insert_before: error_el.tail = el.text el.text = None el.insert(0, error_el) else: el.append(error_el) else: parent = el.getparent() pos = parent.index(el) if self.insert_before: parent.insert(pos, error_el) else: error_el.tail = el.tail el.tail = None parent.insert(pos+1, error_el)
Example #10
Source File: formfill.py From aws-lambda-lxml with GNU General Public License v3.0 | 5 votes |
def __call__(self, el, is_block, message): error_el = el.makeelement(self.error_container_tag) if self.error_message_class: error_el.set('class', self.error_message_class) if is_block and self.error_block_class: error_el.set('class', error_el.get('class', '')+' '+self.error_block_class) if message is None or message == '': message = self.default_message if isinstance(message, ElementBase): error_el.append(message) else: assert isinstance(message, basestring), ( "Bad message; should be a string or element: %r" % message) error_el.text = message or self.default_message if is_block and self.block_inside: if self.insert_before: error_el.tail = el.text el.text = None el.insert(0, error_el) else: el.append(error_el) else: parent = el.getparent() pos = parent.index(el) if self.insert_before: parent.insert(pos, error_el) else: error_el.tail = el.tail el.tail = None parent.insert(pos+1, error_el)
Example #11
Source File: formfill.py From aws-lambda-lxml with GNU General Public License v3.0 | 5 votes |
def __call__(self, el, is_block, message): error_el = el.makeelement(self.error_container_tag) if self.error_message_class: error_el.set('class', self.error_message_class) if is_block and self.error_block_class: error_el.set('class', error_el.get('class', '')+' '+self.error_block_class) if message is None or message == '': message = self.default_message if isinstance(message, ElementBase): error_el.append(message) else: assert isinstance(message, basestring), ( "Bad message; should be a string or element: %r" % message) error_el.text = message or self.default_message if is_block and self.block_inside: if self.insert_before: error_el.tail = el.text el.text = None el.insert(0, error_el) else: el.append(error_el) else: parent = el.getparent() pos = parent.index(el) if self.insert_before: parent.insert(pos, error_el) else: error_el.tail = el.tail el.tail = None parent.insert(pos+1, error_el)
Example #12
Source File: formfill.py From learn_python3_spider with MIT License | 5 votes |
def __call__(self, el, is_block, message): error_el = el.makeelement(self.error_container_tag) if self.error_message_class: error_el.set('class', self.error_message_class) if is_block and self.error_block_class: error_el.set('class', error_el.get('class', '')+' '+self.error_block_class) if message is None or message == '': message = self.default_message if isinstance(message, ElementBase): error_el.append(message) else: assert isinstance(message, basestring), ( "Bad message; should be a string or element: %r" % message) error_el.text = message or self.default_message if is_block and self.block_inside: if self.insert_before: error_el.tail = el.text el.text = None el.insert(0, error_el) else: el.append(error_el) else: parent = el.getparent() pos = parent.index(el) if self.insert_before: parent.insert(pos, error_el) else: error_el.tail = el.tail el.tail = None parent.insert(pos+1, error_el)
Example #13
Source File: formfill.py From stopstalk-deployment with MIT License | 5 votes |
def __call__(self, el, is_block, message): error_el = el.makeelement(self.error_container_tag) if self.error_message_class: error_el.set('class', self.error_message_class) if is_block and self.error_block_class: error_el.set('class', error_el.get('class', '')+' '+self.error_block_class) if message is None or message == '': message = self.default_message if isinstance(message, ElementBase): error_el.append(message) else: assert isinstance(message, basestring), ( "Bad message; should be a string or element: %r" % message) error_el.text = message or self.default_message if is_block and self.block_inside: if self.insert_before: error_el.tail = el.text el.text = None el.insert(0, error_el) else: el.append(error_el) else: parent = el.getparent() pos = parent.index(el) if self.insert_before: parent.insert(pos, error_el) else: error_el.tail = el.tail el.tail = None parent.insert(pos+1, error_el)
Example #14
Source File: formfill.py From lambda-text-extractor with Apache License 2.0 | 5 votes |
def __call__(self, el, is_block, message): error_el = el.makeelement(self.error_container_tag) if self.error_message_class: error_el.set('class', self.error_message_class) if is_block and self.error_block_class: error_el.set('class', error_el.get('class', '')+' '+self.error_block_class) if message is None or message == '': message = self.default_message if isinstance(message, ElementBase): error_el.append(message) else: assert isinstance(message, basestring), ( "Bad message; should be a string or element: %r" % message) error_el.text = message or self.default_message if is_block and self.block_inside: if self.insert_before: error_el.tail = el.text el.text = None el.insert(0, error_el) else: el.append(error_el) else: parent = el.getparent() pos = parent.index(el) if self.insert_before: parent.insert(pos, error_el) else: error_el.tail = el.tail el.tail = None parent.insert(pos+1, error_el)
Example #15
Source File: formfill.py From lambda-text-extractor with Apache License 2.0 | 5 votes |
def __call__(self, el, is_block, message): error_el = el.makeelement(self.error_container_tag) if self.error_message_class: error_el.set('class', self.error_message_class) if is_block and self.error_block_class: error_el.set('class', error_el.get('class', '')+' '+self.error_block_class) if message is None or message == '': message = self.default_message if isinstance(message, ElementBase): error_el.append(message) else: assert isinstance(message, basestring), ( "Bad message; should be a string or element: %r" % message) error_el.text = message or self.default_message if is_block and self.block_inside: if self.insert_before: error_el.tail = el.text el.text = None el.insert(0, error_el) else: el.append(error_el) else: parent = el.getparent() pos = parent.index(el) if self.insert_before: parent.insert(pos, error_el) else: error_el.tail = el.tail el.tail = None parent.insert(pos+1, error_el)
Example #16
Source File: xmlclass.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def GenerateAnyInfos(infos): def GetTextElement(tree): if infos["namespace"][0] == "##any": return tree.xpath("p")[0] return tree.xpath("ns:p", namespaces={"ns": infos["namespace"][0]})[0] def ExtractAny(tree): return GetTextElement(tree).text def GenerateAny(tree, value): GetTextElement(tree).text = etree.CDATA(value) def InitialAny(): if infos["namespace"][0] == "##any": element_name = "p" else: element_name = "{%s}p" % infos["namespace"][0] p = etree.Element(element_name) p.text = etree.CDATA("") return p return { "type": COMPLEXTYPE, "extract": ExtractAny, "generate": GenerateAny, "initial": InitialAny, "check": lambda x: isinstance(x, (string_types, etree.ElementBase)) }