rattail.vendors.catalogs

Vendor Catalogs

class rattail.vendors.catalogs.CatalogParser(config=None, **kwargs)[source]

Base class for all vendor catalog parsers.

Note

As of this writing the config param is technically optional for the class constructor method, but that will certainly change some day. Please be sure to pass a config param when instantiating parsers in your code.

vendor_key

Key for the vendor. This key will be used to locate an entry in the settings table, e.g. 'rattail.vendor.unfi' for a key of 'unfi'. The value of this setting must be an exact match to either a rattail.db.model.Vendor.uuid or rattail.db.model.Vendor.id within the system. However this value may also be None (the default), in which case the user must ultimately specify which vendor should be used for the data import.

decimal(value, scale=4)[source]

Convert a value to a decimal, unless it’s None.

int_(value)[source]

Convert a value to an integer.

property key

Key for the parser. Must be unique among all catalog parsers.

make_row()[source]

Create and return a new row, suitable for use in a vendor catalog batch. The row will be empty and not yet part of any database session.

Returns:

A VendorCatalogBatchRow instance.

parse_effective_date(path)[source]

Parse the overall effective date for a catalog file.

parse_rows(data_path, progress=None)[source]

Parse the given data file, returning all rows found within it.

exception rattail.vendors.catalogs.CatalogParserNotFound(key)[source]

Exception raised when a vendor catalog parser is required, but cannot be located.

rattail.vendors.catalogs.get_catalog_parser(key)[source]

Fetch a vendor catalog parser by key. If the parser class can be located, this will return an instance thereof; otherwise returns None.

rattail.vendors.catalogs.get_catalog_parsers()[source]

Returns a dictionary of installed vendor catalog parser classes.

rattail.vendors.catalogs.iter_catalog_parsers()[source]

Returns an iterator over the installed vendor catalog parsers.

rattail.vendors.catalogs.require_catalog_parser(key)[source]

Fetch a vendor catalog parser by key. If the parser class can be located, this will return an instance thereof; otherwise raises an exception.