importers Package

importers Package

Database import

accountimporter Module

class stoqlib.importers.accountimporter.AccountImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['parent_account', 'description', 'account_type', 'bank_number', 'bank_branch', 'bank_account']
process_one(data, fields, store)[source]

accounttransactionimporter Module

class stoqlib.importers.accounttransactionimporter.AccountTransactionImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['parent_source', 'source', 'parent_dest', 'dest', 'date', 'code', 'description', 'value']
process_one(data, fields, store)[source]

branchimporter Module

class stoqlib.importers.branchimporter.BranchImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['name', 'fancy_name', 'phone_number', 'fax_number', 'state_registry', 'cnpj', 'city', 'country', 'state', 'street', 'streetnumber', 'district', 'postal_code']
branches = []
process_one(data, fields, store)[source]
when_done(store)[source]

clientimporter Module

class stoqlib.importers.clientimporter.ClientImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['name', 'phone_number', 'mobile_number', 'email', 'rg', 'cpf', 'city', 'country', 'state', 'street', 'streetnumber', 'district']
process_one(data, fields, store)[source]

creditproviderimporter Module

class stoqlib.importers.creditproviderimporter.CreditProviderImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['name', 'phone_number', 'mobile_number', 'email', 'cnpj', 'fancy_name', 'state_registry', 'city', 'country', 'state', 'street', 'streetnumber', 'district', 'provider_name']
process_one(data, fields, store)[source]

csvimporter Module

CSV import classes

class stoqlib.importers.csvimporter.CSVRow(item, field_names)[source]

Bases: object

A row in a CSV file

class stoqlib.importers.csvimporter.CSVImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.importer.Importer

Class to assist the process of importing csv files.

Variables:
  • fields – field names, a list of strings
  • optional_fields – optional field names, a list of strings
  • dialect – optional, csv dialect, defaults to excel
fields = []
optional_fields = []
dialect = 'excel'
feed(fp, filename='<stdin>')[source]
get_n_items()[source]
process_item(store, item_no)[source]
parse_date(data)[source]
parse_multi(domain_class, field, store)[source]
process_one(row, fields, store)[source]

Processes one line in a csv file, you can access the columns using attributes on the data object. :param row: object representing a row in the input :param fields: a list of fields set in data :param store: a store

read(iterable)[source]

This can be overridden by as subclass which wishes to specialize the CSV reader. :param iterable: a sequence of lines which are going to be read :returns: a sequence of parsed items

employeeimporter Module

class stoqlib.importers.employeeimporter.EmployeeImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

create_users = False
fields = ['name', 'phone_number', 'mobile_number', 'email', 'rg', 'cpf', 'role', 'employee_number', 'start', 'salary', 'city', 'country', 'state', 'street', 'streetnumber', 'district', 'profile', 'username', 'password']
process_one(data, fields, store)[source]

gnucashimporter Module

GnuCash importing

class stoqlib.importers.gnucashimporter.GnuCashXMLImporter[source]

Bases: stoqlib.importers.importer.Importer

Class to assist the process of importing gnucash files.

feed_file(filename)[source]
feed(fp)[source]
get_n_items()[source]
process_item(store, i)[source]

importer Module

class stoqlib.importers.importer.Importer(items=500, dry=False)[source]

Bases: object

Class to assist the process of importing csv files.

feed_file(filename)[source]

Feeds csv data from filename to the importer :param filename: filename

set_items_per_commit(items)[source]

Sets the number of items which should be parsed between commits. Defaults to 500. -1 means that the whole file should be parsed before committing :param items: number of items or

set_dry(dry)[source]

Tells the CSVImporter to run in dry mode, eg without committing anything. :param dry: dry mode

process(store=None)[source]

Do the main logic, create stores, import items etc

feed(fp, filename='<stdin>')[source]

Feeds csv data from an iterable :param fp: a file descriptor :param filename: optinal, name of input file

get_n_items()[source]
process_item(store, item_no)[source]

:returns True if the item was imported, False if not

before_start(store)[source]

This is called before all the lines are parsed but after creating a store.

when_done(store)[source]

This is called after all the lines are parsed but before committing.

stoqlib.importers.importer.get_by_type(importer_type)[source]

Gets an importers class, instantiates it returns it :param importer_type: an importer :type importer_type: string :returns: an importer instance :type: Importer subclass

invoiceimporter Module

class stoqlib.importers.invoiceimporter.InvoiceImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['layout_description', 'layout_width', 'layout_height', 'field_name', 'field_x', 'field_y', 'field_width', 'field_height']
process_one(data, fields, store)[source]

ofximporter Module

OFX importing

class stoqlib.importers.ofximporter.OFXTagParser[source]

Bases: sgmllib.SGMLParser

unknown_starttag(tag, attrs)[source]
unknown_endtag(tag)[source]
handle_data(data)[source]
class stoqlib.importers.ofximporter.OFXImporter[source]

Bases: stoqlib.importers.importer.Importer

Class to assist the process of importing ofx files.

feed(fp, filename='<stdin>')[source]
before_start(store)[source]
get_n_items()[source]
process_item(store, i)[source]
when_done(store)[source]
get_account_id()[source]

productimporter Module

class stoqlib.importers.productimporter.ProductImporter[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['base_category', 'barcode', 'category', 'description', 'price', 'cost', 'commission', 'commission2', 'markup', 'markup2', 'ncm']
optional_fields = ['unit']
process_one(data, fields, store)[source]

purchaseimporter Module

class stoqlib.importers.purchaseimporter.PurchaseImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['supplier_name', 'transporter_name', 'branch_name', 'user_name', 'payment_method', 'due_date', 'sellable_list', 'invoice', 'quantity']
process_one(data, fields, store)[source]

saleimporter Module

class stoqlib.importers.saleimporter.SaleImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['branch_name', 'client_name', 'salesperson_name', 'payment_method', 'product_list', 'coupon_id', 'open_date', 'due_date']
process_one(data, fields, store)[source]

serviceimporter Module

class stoqlib.importers.serviceimporter.ServiceImporter[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['description', 'barcode', 'price', 'cost']
process_one(data, fields, store)[source]

stoqlibexamples Module

Import CSVs for the Stoqlib example database

stoqlib.importers.stoqlibexamples.create(utilities=False, create_users=False)[source]

supplierimporter Module

class stoqlib.importers.supplierimporter.SupplierImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['name', 'phone_number', 'mobile_number', 'email', 'cnpj', 'state_registry', 'city', 'country', 'state', 'street', 'streetnumber', 'district']
suppliers = []
process_one(data, fields, store)[source]
when_done(store)[source]

transferimporter Module

class stoqlib.importers.transferimporter.TransferImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['source_branch_name', 'source_employee_name', 'dest_branch_name', 'dest_employee_name', 'sellable_list', 'open_date', 'receival_date', 'quantity']
process_one(data, fields, store)[source]

transporterimporter Module

class stoqlib.importers.transporterimporter.TransporterImporter(lines=500, dry=False)[source]

Bases: stoqlib.importers.csvimporter.CSVImporter

fields = ['name', 'phone_number', 'mobile_number', 'email', 'cnpj', 'state_registry', 'city', 'country', 'state', 'street', 'streetnumber', 'district', 'open_contract', 'freight_percentage']
process_one(data, fields, store)[source]