def _format_row_xml(self, row): """ Utility method for turning an row dictionary into valid xml for entering or updating a row into the table @param employee: Dictionary containing row data information. """ xml_fields = '' for k, v in row.iteritems(): xml_fields += make_field_xml(k, v, pre='\t', post='\n') xml = "<row>\n{}</row>".format(xml_fields) return xml
def _format_report_xml(self, fields, title='My Custom Report', report_format='pdf'): """ Utility method for turning an employee dictionary into valid employee xml. @param fields: List containing report fields. """ xml_fields = '' for field in fields: xml_fields += make_field_xml(field, None, pre='\t\t', post='\n') # Really cheesy way to build XML... this should probably be replaced at some point. xml = '''<report output="{0}">\n\t<title>{1}</title>\n\t<fields>\n{2}\t</fields>\n</report>'''.format(report_format, title, xml_fields) return xml
def _format_employee_xml(self, employee): """ Utility method for turning an employee dictionary into valid employee xml. @param employee: Dictionary containing employee information. """ xml_fields = '' for key in employee: if not self.employee_fields.get(key): raise UserWarning("You passed in an invalid field") else: xml_fields += make_field_xml(key, employee[key], pre='\t', post='\n') # Really cheesy way to build XML... this should probably be replaced at some point. xml = "<employee>\n{}</employee>".format(xml_fields) return xml