endi.export package¶
Submodules¶
endi.export.activity_pdf module¶
Utilities used to export an activity in pdf format
- endi.export.activity_pdf.activity_pdf(activity, request)¶
Generates the pdf output for a given activity
- Type renvoyé:
io.BytesIO instance
endi.export.cegid module¶
- class endi.export.cegid.BaseWriter(context, request)¶
Bases :
XlsExporter- amount_precision = 5¶
- encoding = 'utf-8'¶
- extension = 'xlsx'¶
- format_compte_cg(value)¶
- format_credit_debit(value)¶
Format the debit entry to get a clean float in our export 12000 => 120,00
- format_date(date_object)¶
- format_libelle(libelle)¶
truncate the libelle in order to suit the accounting software specs
- format_row(row) List¶
The render method expects rows as lists, here we switch our row format from dict to list respecting the order of the headers
- format_type_(value)¶
- mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'¶
- class endi.export.cegid.ExpensePaymentWriter(context, request)¶
Bases :
BaseWriter- amount_precision = 2¶
- headers = ({'name': 'type_', 'label': 'Type'}, {'name': 'date', 'label': 'DATE', 'typ': 'date'}, {'name': 'code_journal', 'label': 'JOURNAL'}, {'name': 'compte_cg', 'label': 'GENERAL'}, {'name': 'compte_tiers', 'label': 'AUXILIAIRE'}, {'name': 'sens', 'label': 'SENS'}, {'name': 'credit_debit', 'label': 'MONTANT', 'typ': 'number'}, {'name': 'libelle', 'label': 'LIBELLE'}, {'name': 'reference', 'label': 'REFERENCE'}, {'name': 'num_analytique', 'label': 'SECTION/AXE A1'}, {'name': 'void', 'label': 'SECTION/AXE A2'}, {'name': 'void', 'label': 'SECTION/AXE A3'}, {'name': 'void', 'label': 'SECTION/AXE A4'}, {'name': 'void', 'label': 'SECTION/AXE A5'})¶
- class endi.export.cegid.ExpenseWriter(context, request)¶
Bases :
BaseWriterexpense xlsx writer
- amount_precision = 2¶
- headers = ({'name': 'type_', 'label': 'Type'}, {'name': 'date', 'label': 'DATE', 'typ': 'date'}, {'name': 'code_journal', 'label': 'JOURNAL'}, {'name': 'compte_cg', 'label': 'GENERAL'}, {'name': 'compte_tiers', 'label': 'AUXILIAIRE'}, {'name': 'sens', 'label': 'SENS'}, {'name': 'credit_debit', 'label': 'MONTANT', 'typ': 'number'}, {'name': 'libelle', 'label': 'LIBELLE'}, {'name': 'num_endi', 'label': 'REFERENCE'}, {'name': 'num_analytique', 'label': 'SECTION/AXE A1'}, {'name': 'void', 'label': 'SECTION/AXE A2'}, {'name': 'void', 'label': 'SECTION/AXE A3'}, {'name': 'void', 'label': 'SECTION/AXE A4'}, {'name': 'void', 'label': 'SECTION/AXE A5'})¶
- class endi.export.cegid.InvoiceWriter(context, request)¶
Bases :
BaseWriterInvoice writer
- headers = ({'name': 'type_', 'label': 'Type'}, {'name': 'date', 'label': 'DATE', 'typ': 'date'}, {'name': 'code_journal', 'label': 'JOURNAL'}, {'name': 'compte_cg', 'label': 'GENERAL'}, {'name': 'compte_tiers', 'label': 'AUXILIAIRE'}, {'name': 'sens', 'label': 'SENS'}, {'name': 'credit_debit', 'label': 'MONTANT', 'typ': 'number'}, {'name': 'libelle', 'label': 'LIBELLE'}, {'name': 'num_endi', 'label': 'REFERENCE'}, {'name': 'num_analytique', 'label': 'SECTION/AXE A1'}, {'name': 'void', 'label': 'SECTION/AXE A2'}, {'name': 'void', 'label': 'SECTION/AXE A3'}, {'name': 'void', 'label': 'SECTION/AXE A4'}, {'name': 'void', 'label': 'SECTION/AXE A5'})¶
- class endi.export.cegid.PaymentWriter(context, request)¶
Bases :
BaseWriterexpense xlsx writer
- headers = ({'name': 'type_', 'label': 'Type'}, {'name': 'date', 'label': 'DATE', 'typ': 'date'}, {'name': 'code_journal', 'label': 'JOURNAL'}, {'name': 'compte_cg', 'label': 'GENERAL'}, {'name': 'compte_tiers', 'label': 'AUXILIAIRE'}, {'name': 'sens', 'label': 'SENS'}, {'name': 'credit_debit', 'label': 'MONTANT', 'typ': 'number'}, {'name': 'libelle', 'label': 'LIBELLE'}, {'name': 'reference', 'label': 'REFERENCE'}, {'name': 'num_analytique', 'label': 'SECTION/AXE A1'}, {'name': 'void', 'label': 'SECTION/AXE A2'}, {'name': 'void', 'label': 'SECTION/AXE A3'}, {'name': 'void', 'label': 'SECTION/AXE A4'}, {'name': 'void', 'label': 'SECTION/AXE A5'})¶
- class endi.export.cegid.SupplierInvoiceWriter(context, request)¶
Bases :
BaseWriterSupplier invoice writer
- amount_precision = 2¶
- headers = ({'name': 'type_', 'label': 'Type'}, {'name': 'date', 'label': 'DATE', 'typ': 'date'}, {'name': 'code_journal', 'label': 'JOURNAL'}, {'name': 'compte_cg', 'label': 'GENERAL'}, {'name': 'compte_tiers', 'label': 'AUXILIAIRE'}, {'name': 'sens', 'label': 'SENS'}, {'name': 'credit_debit', 'label': 'MONTANT', 'typ': 'number'}, {'name': 'libelle', 'label': 'LIBELLE'}, {'name': 'num_endi', 'label': 'REFERENCE'}, {'name': 'num_analytique', 'label': 'SECTION/AXE A1'}, {'name': 'void', 'label': 'SECTION/AXE A2'}, {'name': 'void', 'label': 'SECTION/AXE A3'}, {'name': 'void', 'label': 'SECTION/AXE A4'}, {'name': 'void', 'label': 'SECTION/AXE A5'})¶
- class endi.export.cegid.SupplierPaymentWriter(context, request)¶
Bases :
BaseWriterSupplier payment xlsx writer
- amount_precision = 2¶
- headers = ({'name': 'type_', 'label': 'Type'}, {'name': 'date', 'label': 'DATE', 'typ': 'date'}, {'name': 'code_journal', 'label': 'JOURNAL'}, {'name': 'compte_cg', 'label': 'GENERAL'}, {'name': 'compte_tiers', 'label': 'AUXILIAIRE'}, {'name': 'sens', 'label': 'SENS'}, {'name': 'credit_debit', 'label': 'MONTANT', 'typ': 'number'}, {'name': 'libelle', 'label': 'LIBELLE'}, {'name': 'num_endi', 'label': 'REFERENCE'}, {'name': 'num_analytique', 'label': 'SECTION/AXE A1'}, {'name': 'void', 'label': 'SECTION/AXE A2'}, {'name': 'void', 'label': 'SECTION/AXE A3'}, {'name': 'void', 'label': 'SECTION/AXE A4'}, {'name': 'void', 'label': 'SECTION/AXE A5'})¶
endi.export.excel module¶
- class endi.export.excel.XlsExporter(worksheet=None, options=None, **kw)¶
Bases :
objectThose options are implemented :
row-level : highlight, hidden document-level: decimal_places
- WIDE_COLUMN_WIDTH = 50¶
- add_breakline()¶
- add_headers(labels)¶
- add_row(labels, options=None)¶
- add_title(title, width)¶
- render(f_buf=None)¶
Definitely render the workbook
- Paramètres:
f_buf (obj) – A file buffer supporting the write and seek
methods
- save_book(f_buf=None)¶
Return a file buffer containing the resulting xls
- Paramètres:
f_buf (obj) – A file buffer supporting the write and seek
methods
- set_column_options(column_index: int, column_style_name=typing.Union[str, NoneType]) None¶
Sets column options/styles
- title = 'Export'¶
- endi.export.excel.get_number_format(decimal_places=0, percentage=False) str¶
Build excel number formatting string
>>> get_number_format() '#,##0'
>>> get_number_format(1) '#,##0.0'
>>> get_number_format(1, True) '#,##0.0%'
- Paramètres:
decimal_places –
percentage –
- Renvoie:
- endi.export.excel.make_excel_view(filename_builder, factory)¶
Build an excel view of a model :param filename_builder: a callable that take the request as arg and
return a filename
- Paramètres:
factory – the Xls factory that should be used to wrap the request context the factory should provide a render method returning a file like object
endi.export.expense_excel module¶
Tools used to export datas in xls format
- class endi.export.expense_excel.Column(label, index=None, last_index=None)¶
Bases :
objectA column object
- property end_index¶
- reset_ht()¶
- set_index(start, end=None)¶
- property start_index¶
- class endi.export.expense_excel.StaticColumn(label, key, formatter=None, style=None, nb_col=None, index=None, last_index=None)¶
Bases :
ColumnA static column object representing static datas representation
- get_val(line)¶
- static = True¶
- class endi.export.expense_excel.TypedColumn(expense_type, label=None, index=None, last_index=None)¶
Bases :
Column- get_val(line)¶
- static = False¶
- class endi.export.expense_excel.XlsExpense(expensesheet)¶
Bases :
XlsWriterXls exporter of an expensesheet object
Provide two sheets : the expenses and the kilometric datas
- get_cell_val(line, column, by_id=True)¶
For a given expense line, check if a value should be provided in the given column
- get_column_cell(column)¶
Return the cell corresponding to a given column
- get_columns()¶
Retrieve all columns and define a global column attribute :param internal: are we asking columns for internal expenses
- get_disabled_types_columns()¶
- get_formatted_cell_val(line, column)¶
For a given expense line, check if a value should be provided in the given column
- get_km_column()¶
Return the columns associated to km expenses
- get_merged_cells(start, end)¶
returned merged cells of the current line index
- get_tel_column()¶
Return the columns associated to telephonic expenses
- render()¶
Return the current excel export as a String buffer (BytesIO)
- set_col_width(col_letter, width, force=False)¶
Set the width of a given column
- title = 'NDF'¶
- write_accord()¶
Write the endline
- write_activity_expenses()¶
write the activity expense table to the current worksheet
- write_code()¶
write the company code in the header
- write_company()¶
write the company code in the header
- write_expense_table(category)¶
write expenses tables for the given category
- write_full_line(txt, start=1, end=10)¶
Write a full line, merging cells
- write_global_total_ht()¶
Write the total ht in the upper part of the sheet
- write_global_total_ttc()¶
Write the total tva in the upper part of the sheet
- write_global_total_tva()¶
Write the total tva in the upper part of the sheet
- write_internal_expenses()¶
write the internal expense table to the current worksheet
- write_km_book()¶
Write the km book associated to this expenses
- write_number()¶
write the expense sheet id in the header
- write_period()¶
write the period in the header
- write_table(columns, lines)¶
write a table with headers and content :param columns: list of dict :params lines: list of models to be written
Write table footer (total, ht, tva, km)
- Paramètres:
columns (list) – The columns as described in the static vars here
above :param list lines: The lines presented in this table
- write_table_header(columns)¶
Write the table’s header and its subheader
- write_title()¶
write the title in the header
- write_total()¶
write the final total
- write_user()¶
write the username in the header
- write_vehicle_information()¶
endi.export.ods module¶
- class endi.export.ods.OdsExporter(options: Optional[dict] = None)¶
Bases :
objectThose options are implemented :
row-level : highlight, hidden document-level: decimal_places
- add_breakline()¶
- add_headers(datas)¶
- add_row(datas, options=None)¶
- add_title(title, width)¶
- render(f_buf=None)¶
- set_column_options(column_index: int, column_style_name=typing.Union[str, NoneType]) None¶
Sets column options/styles
- title = 'Export'¶
endi.export.sage module¶
Sage exports tools
- class endi.export.sage.SageCsvWriter(context, request)¶
Bases :
CsvExporterWrite Sage csv files :param datas: The datas to export list of dict :param headers: The translation tuple between input and output column names
- amount_precision = 2¶
- delimiter = ';'¶
- encoding = 'iso-8859-15'¶
- extension = 'txt'¶
- format_credit(credit)¶
format the credit entry to get a clean float
- format_date(date_object)¶
format date for sage export
- format_debit(debit)¶
Format the debit entry to get a clean float in our export 12000 => 120,00
- format_echeance(date_object)¶
format date for sage export
- format_libelle(libelle)¶
truncate the libelle in order to suit the accounting software specs
- headers = ()¶
- mimetype = 'application/csv'¶
- quotechar = '"'¶
- class endi.export.sage.SageExpenseCsvWriter(context, request)¶
Bases :
SageCsvWriterExpense CsvWriter
- headers = ({'name': 'num_endi', 'label': 'Numéro de pièce'}, {'name': 'code_journal', 'label': 'Code Journal'}, {'name': 'date', 'label': 'Date de pièce'}, {'name': 'compte_cg', 'label': 'N° compte général'}, {'name': 'num_feuille', 'label': 'Numéro de note de dépenses'}, {'name': 'compte_tiers', 'label': 'Numéro de compte tiers'}, {'name': 'code_tva', 'label': 'Code taxe'}, {'name': 'libelle', 'label': "Libellé d'écriture"}, {'name': 'debit', 'label': 'Montant débit'}, {'name': 'credit', 'label': 'Montant crédit'}, {'name': 'type_', 'label': 'Type de ligne'}, {'name': 'num_analytique', 'label': 'Numéro analytique'}, {'name': 'num_endi', 'label': 'Référence'})¶
- class endi.export.sage.SageExpensePaymentCsvWriter(context, request)¶
Bases :
SageCsvWriter- headers = ({'name': 'reference', 'label': 'Référence'}, {'name': 'code_journal', 'label': 'Code Journal'}, {'name': 'date', 'label': 'Date de pièce'}, {'name': 'compte_cg', 'label': 'N° compte général'}, {'name': 'mode', 'label': 'Mode de règlement'}, {'name': 'compte_tiers', 'label': 'Numéro de compte tiers'}, {'name': 'code_taxe', 'label': 'Code taxe'}, {'name': 'libelle', 'label': "Libellé d'écriture"}, {'name': 'debit', 'label': 'Montant débit'}, {'name': 'credit', 'label': 'Montant crédit'}, {'name': 'type_', 'label': 'Type de ligne'}, {'name': 'num_analytique', 'label': 'Numéro analytique'})¶
- class endi.export.sage.SageInvoiceCsvWriter(context, request)¶
Bases :
SageCsvWriterSage invoice csv writer
- amount_precision = 5¶
- headers = ({'name': 'num_endi', 'label': 'Numéro de pièce'}, {'name': 'code_journal', 'label': 'Code Journal'}, {'name': 'date', 'label': 'Date de pièce'}, {'name': 'compte_cg', 'label': 'N° compte général'}, {'name': 'num_endi', 'label': 'Numéro de facture'}, {'name': 'compte_tiers', 'label': 'Numéro de compte tiers'}, {'name': 'code_tva', 'label': 'Code taxe'}, {'name': 'libelle', 'label': "Libellé d'écriture"}, {'name': 'echeance', 'label': "Date d'échéance"}, {'name': 'debit', 'label': 'Montant débit'}, {'name': 'credit', 'label': 'Montant crédit'}, {'name': 'type_', 'label': 'Type de ligne'}, {'name': 'num_analytique', 'label': 'Numéro analytique'})¶
- class endi.export.sage.SagePaymentCsvWriter(context, request)¶
Bases :
SageCsvWriterPayment csv writer
- amount_precision = 5¶
- headers = ({'name': 'reference', 'label': 'Référence'}, {'name': 'code_journal', 'label': 'Code Journal'}, {'name': 'date', 'label': 'Date de pièce'}, {'name': 'compte_cg', 'label': 'N° compte général'}, {'name': 'mode', 'label': 'Mode de règlement'}, {'name': 'compte_tiers', 'label': 'Numéro de compte tiers'}, {'name': 'code_taxe', 'label': 'Code taxe'}, {'name': 'libelle', 'label': "Libellé d'écriture"}, {'name': 'debit', 'label': 'Montant débit'}, {'name': 'credit', 'label': 'Montant crédit'}, {'name': 'type_', 'label': 'Type de ligne'}, {'name': 'num_analytique', 'label': 'Numéro analytique'})¶
- class endi.export.sage.SageSupplierInvoiceCsvWriter(context, request)¶
Bases :
SageCsvWriter- headers = ({'name': 'num_endi', 'label': 'Numéro de pièce'}, {'name': 'code_journal', 'label': 'Code Journal'}, {'name': 'date', 'label': 'Date de pièce'}, {'name': 'compte_cg', 'label': 'N° compte général'}, {'name': 'num_feuille', 'label': 'Numéro de facture'}, {'name': 'compte_tiers', 'label': 'Numéro de compte tiers'}, {'name': 'code_tva', 'label': 'Code taxe'}, {'name': 'libelle', 'label': "Libellé d'écriture"}, {'name': 'debit', 'label': 'Montant débit'}, {'name': 'credit', 'label': 'Montant crédit'}, {'name': 'type_', 'label': 'Type de ligne'}, {'name': 'num_analytique', 'label': 'Numéro analytique'})¶
- class endi.export.sage.SageSupplierPaymentCsvWriter(context, request)¶
Bases :
SageCsvWriter- headers = ({'name': 'num_endi', 'label': 'Numéro de pièce'}, {'name': 'code_journal', 'label': 'Code Journal'}, {'name': 'date', 'label': 'Date de pièce'}, {'name': 'compte_cg', 'label': 'N° compte général'}, {'name': 'mode', 'label': 'Mode de règlement'}, {'name': 'compte_tiers', 'label': 'Numéro de compte tiers'}, {'name': 'code_taxe', 'label': 'Code taxe'}, {'name': 'libelle', 'label': "Libellé d'écriture"}, {'name': 'debit', 'label': 'Montant débit'}, {'name': 'credit', 'label': 'Montant crédit'}, {'name': 'type_', 'label': 'Type de ligne'}, {'name': 'num_analytique', 'label': 'Numéro analytique'}, {'name': 'reference', 'label': 'Référence'})¶
endi.export.sage_generation_expert module¶
- class endi.export.sage_generation_expert.BaseWriter(context, request)¶
Bases :
XlsExporter- amount_precision = 5¶
- encoding = 'utf-8'¶
- extension = 'xlsx'¶
- format_compte_cg(value)¶
- format_credit(credit)¶
format the credit entry to get a clean float
- format_currency(value)¶
- format_date(date_object)¶
- format_debit(value)¶
Format the debit entry to get a clean float in our export 12000 => 120,00
- format_libelle(libelle)¶
truncate the libelle in order to suit the accounting software specs
- format_num_analytique(value)¶
- mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'¶
- class endi.export.sage_generation_expert.ExpensePaymentWriter(context, request)¶
Bases :
BaseWriter- amount_precision = 2¶
- headers = ({'name': 'date', 'label': 'Date piece', 'typ': 'date'}, {'name': 'code_journal', 'label': 'Code journal'}, {'name': 'compte_cg', 'label': 'N° compte general'}, {'name': 'reference', 'label': 'N° pièce'}, {'name': 'libelle', 'label': 'Libelle ecriture'}, {'name': 'debit', 'label': 'Montant debit', 'typ': 'number'}, {'name': 'credit', 'label': 'Montant credit', 'typ': 'number'}, {'name': 'currency', 'label': 'Devise'}, {'name': 'num_analytique', 'label': 'code analytique'})¶
- class endi.export.sage_generation_expert.ExpenseWriter(context, request)¶
Bases :
BaseWriterexpense xlsx writer
- amount_precision = 2¶
- headers = ({'name': 'date', 'label': 'Date piece', 'typ': 'date'}, {'name': 'code_journal', 'label': 'Code journal'}, {'name': 'compte_cg', 'label': 'N° compte general'}, {'name': 'num_feuille', 'label': 'Numéro de note de dépenses'}, {'name': 'libelle', 'label': 'Libelle ecriture'}, {'name': 'debit', 'label': 'Montant debit', 'typ': 'number'}, {'name': 'credit', 'label': 'Montant credit', 'typ': 'number'}, {'name': 'currency', 'label': 'Devise'}, {'name': 'num_analytique', 'label': 'code analytique'})¶
- class endi.export.sage_generation_expert.InvoiceWriter(context, request)¶
Bases :
BaseWriterInvoice writer
- headers = ({'name': 'date', 'label': 'Date piece', 'typ': 'date'}, {'name': 'code_journal', 'label': 'Code journal'}, {'name': 'compte_cg', 'label': 'N° compte general'}, {'name': 'num_endi', 'label': 'Numéro de pièce'}, {'name': 'libelle', 'label': 'Libelle ecriture'}, {'name': 'debit', 'label': 'Montant debit', 'typ': 'number'}, {'name': 'credit', 'label': 'Montant credit', 'typ': 'number'}, {'name': 'currency', 'label': 'Devise'}, {'name': 'num_analytique', 'label': 'code analytique'})¶
- class endi.export.sage_generation_expert.PaymentWriter(context, request)¶
Bases :
BaseWriterexpense xlsx writer
- headers = ({'name': 'date', 'label': 'Date piece', 'typ': 'date'}, {'name': 'code_journal', 'label': 'Code journal'}, {'name': 'compte_cg', 'label': 'N° compte general'}, {'name': 'reference', 'label': 'N° pièce'}, {'name': 'libelle', 'label': 'Libelle ecriture'}, {'name': 'debit', 'label': 'Montant debit', 'typ': 'number'}, {'name': 'credit', 'label': 'Montant credit', 'typ': 'number'}, {'name': 'currency', 'label': 'Devise'}, {'name': 'num_analytique', 'label': 'code analytique'})¶
- class endi.export.sage_generation_expert.SupplierInvoiceWriter(context, request)¶
Bases :
BaseWriterSupplier invoice writer
- amount_precision = 2¶
- headers = ({'name': 'date', 'label': 'Date piece', 'typ': 'date'}, {'name': 'code_journal', 'label': 'Code journal'}, {'name': 'compte_cg', 'label': 'N° compte general'}, {'name': 'num_endi', 'label': 'Numéro de pièce'}, {'name': 'libelle', 'label': 'Libelle ecriture'}, {'name': 'debit', 'label': 'Montant debit', 'typ': 'number'}, {'name': 'credit', 'label': 'Montant credit', 'typ': 'number'}, {'name': 'currency', 'label': 'Devise'}, {'name': 'num_analytique', 'label': 'code analytique'})¶
- class endi.export.sage_generation_expert.SupplierPaymentWriter(context, request)¶
Bases :
BaseWriterSupplier payment xlsx writer
- amount_precision = 2¶
- headers = ({'name': 'date', 'label': 'Date piece', 'typ': 'date'}, {'name': 'code_journal', 'label': 'Code journal'}, {'name': 'compte_cg', 'label': 'N° compte general'}, {'name': 'reference', 'label': 'N° pièce'}, {'name': 'libelle', 'label': 'Libelle ecriture'}, {'name': 'debit', 'label': 'Montant debit', 'typ': 'number'}, {'name': 'credit', 'label': 'Montant credit', 'typ': 'number'}, {'name': 'currency', 'label': 'Devise'}, {'name': 'num_analytique', 'label': 'code analytique'})¶
endi.export.task_pdf module¶
- endi.export.task_pdf.ensure_task_pdf_persisted(task, request)¶
Persist a task’s pdf if it’s not done yet
- Renvoie:
A buffer with the pdf data
- Type renvoyé:
IO-like buffer
- endi.export.task_pdf.task_bulk_pdf(tasks, request)¶
Produce a pdf containing merged tasks pdf
- Paramètres:
tasks (list) – list of Task objects
- endi.export.task_pdf.task_pdf(task, request)¶
Generates the pdf output for a given task
- Type renvoyé:
io.BytesIO instance
endi.export.utils module¶
Export utilities:
Tools to build file responses (pdf, xls …)
- class endi.export.utils.JSONExportSQLAlchemySchemaNode(*args, **kw)¶
Bases :
SQLAlchemySchemaNodePatched version of SQLAchemySchemaNode dedicated to import/export of complex objects as JSON
This is not classical JSON : every scalar is encoded as string (ex: False -> « false », 1.2 -> « 1.2 »). But what matters most here is not interoperability, but the ability to import/export from/to enDI and the reliability/maintenaibility of that process with evolving models.
Contains bugfixes, configurability and design change
Unplug from the config set in SQLA models ({« info »: {« colanderalchemy »: …}})
Possible to configure via SchemaNode class attributes rather than imperatively : - the SQLA underlying model - the overrides / includes / excludes params.
fix 1 bug on dictification
fix 2 limitations and 1 bug in nested relationship
Automatic instantiating of subclasses when using SA polymorphism
- CLASS = None¶
- EXCLUDES = None¶
- INCLUDES = None¶
- OVERRIDES = None¶
- dictify(obj)¶
Overrided to fix a colanderalchemy bug: if a child schema is called « items »¹
Root bug cause is ColanderAlchemy accesses column information through column_attrs/relationship_attrs attributes, but this is unreliable as namespace own attributes, (eg column_attrs.items()) are polutting namespaces.
Fixing that by accessing column information with the dict-like API of column_attrs/relationship_attrs.
- get_schema_from_relationship(prop, overrides)¶
Pimps this method so that the child nodes are JSONExportSQLAlchemySchemaNode
Works around two limitations of two SQLAlchemyNode : - child schema (mappings) are SQLAlchemyNode, not our customized clas - Sequences schemas items are plain SchemaNode, not even SQLAlchemyNode
And one bug: - default cannot be overrided imperatively :param prop: :param overrides: :return:
- objectify(dict_, context=None)¶
Return an object representing
dict_using schema information.The schema will be used to choose how the data in the structure will be restored into SQLAlchemy model objects. The incoming
dict_structure corresponds with one that may be created from thedictify()method on the same schema. Relationships and backrefs will be restored in accordance with their specific configurations.The return value of this function will be suitable for adding into an SQLAlchemy session to be committed to a database.
Arguments/Keywords
- dict_
An dictionary or similar data structure to be converted to a an SQLAlchemy object. This data structure should conform to the given schema. For example,
dict_should be an appstruct (such as that returned from a Deform form submission), result of a call to this schema’sdictify()method, or a matching structure with relevant keys and nesting, if applicable.- context
Optional keyword argument that, if supplied, becomes the base object, with attributes and objects being applied to it.
Specify a
contextin the situation where you already have an object that exists already, such as when you have a pre-existing instance of an SQLAlchemy model. If your model is already bound to a session, then this facilitates directly updating the database – just pass in your dict or appstruct, and your existing SQLAlchemy instance ascontextand this method will update all of its attributes.This is a perfect fit for something like a CRUD environment.
Default:
None. Defaults to instantiating a new instance of the mapped class associated with this schema.
- sqla_info_key = 'colanderalchemy_json_export'¶
- endi.export.utils.detect_file_mimetype(filename)¶
Return the headers adapted to the given filename
- endi.export.utils.ensure_encoding_bridge(filedata, encoding)¶
Ensure, if the encoding is not utf-8, that the returned data will not raise an encoding error (if the filedata is provided as a string)
- endi.export.utils.format_filename(filename)¶
Format filename to avoid illegal characters
- Type renvoyé:
- endi.export.utils.get_buffer_value(filebuffer)¶
Return the content of the given filebuffer, handles the different interfaces between opened files and BytesIO containers
- endi.export.utils.slugify(value, allow_unicode=False)¶
Taken from https://github.com/django/django/blob/master/django/utils/text.py Convert to ASCII if “allow_unicode” is False. Convert spaces or repeated dashes to single dashes. Remove characters that aren’t alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace, dashes, and underscores.
- endi.export.utils.store_export_file(context, request, export_file, export_filename, mimetype, encoding='utf-8')¶
Stores the export file containing accounting operations
- endi.export.utils.write_file_to_request(request, filename, buf, mimetype=None, encoding='UTF-8', force_download=True)¶
Write a buffer as request content :param request: Pyramid’s request object :param filename: The destination filename :param buf: The file buffer mostly BytesIO object, should provide a
getvalue method
- Paramètres:
mimetype – file mimetype, defaults to autodetection
force_download – force file downloading instead of inlining
- endi.export.utils.write_headers(request, filename, mimetype, encoding=None, force_download=True)¶
Write the given headers to the current request
endi.export.workshop_pdf module¶
Utilities used to export an workshop in pdf format
- endi.export.workshop_pdf.workshop_pdf(workshop, timeslots, request)¶
Generates the pdf output for a given workshop
- Type renvoyé:
io.BytesIO instance