rattail.sw.locsms.sil – SIL Processing Utilities
This module contains functions for processing SIL, as it pertains to SMS.
Returns the next available batch identifier, incrementing the number to preserve uniqueness.
This could stand to be much more robust; right now it relies on a config file local to the user (i.e. not even machine-wide).
Returns a SIL header suitable for inclusion in a file to be processed by LOC SMS.
If you override batch_creator then you must also provide batch_id. Otherwise you may omit batch_id and Rattail will use its own auto-incremented value for that.
The following additional keyword arguments are recognized:
Returns a SIL record suitable for inclusion in a batch file. The record’s values will come from the positional arguments.
Returns a string version of value, suitable for inclusion within a data record line of a SIL batch. The conversion is done as follows:
If value is None, an empty string is returned.
If it is an integer, it is converted directly to a string (i.e. not quoted).
If it is a string, but contains only digits, it is wrapped in single quotes. If the string contains any apostrophes or commas, it is wrapped in single quotes with the apostrophes escaped. Otherwise it is is returned as-is without quoting.
Generates a SIL file which, when processed by SMS, will create an Inventory Multi-Count document available for import. path determines where the file is written, and batch must be a sequence of tuples of the form:
(upc, cases, units)
Any extra keyword arguments are passed directly to get_header(). Note that several (default) batch header values are provided by this function however. (See source for specifics.)