def get_page_fields(tree, page): page_id = 'page%s' % page['id'].replace('tab', '') page_element = get(tree.xpath('.//div[@id="%s"]' % page_id)) field_list = [] for element in page_element.xpath('.//div[@class="elementwrapper"]'): item = extract_element(element) field_list.append(item) return field_list
def extract_content(self, section): content = get(section) result = { 'text': clean_text(content), } if self.is_text(): # Add extra required fields for the content: self.field_id = get_field_id(section) self.data_triggers = get_data_triggers(section) extra_attrs = get_text_attributes(content) result.update(extra_attrs) return result
def extract_locale_settings(tree): """Extract localised settings available in the tree.""" value_list = ( ('surveyls_title', './/div[@class="surveytitle"]'), ) results = [] for key, selector in value_list: value = get(tree.xpath(selector)) value = get_inner_html(value) value = strip_tags(value) results.append((key, value.strip())) return dict(results)
def get_form_title(tree): """Gets the title of the form.""" title = get(tree.xpath('//div[@class="surveytitle"]')) title_text = get_inner_html(title) return title_text
def get_page_title(section): title = get(section) title = get_inner_html(title) return strip_tags(title)