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).

rattail.sw.locsms.sil.get_header(batch_type='HM', batch_id=None, batch_creator='RATTAIL', **kwargs)

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:

  • batch_destination
  • batch_audit_file
  • batch_response_file
  • batch_ending_date
  • batch_ending_time
  • batch_active_date
  • batch_active_time
  • batch_purge_date
  • batch_action_type
  • batch_description
  • batch_state
  • batch_count
  • batch_macro
  • batch_warning_level
  • batch_maximum_error_count
  • batch_file_version
  • batch_creator_version
  • batch_primary_key
  • batch_specific_command
  • shelf_tag_type
  • batch_execution_priority

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.

rattail.sw.locsms.sil.write_inventory_import(path, batch, progress_factory=None, **kwargs)

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.)

Previous topic


Next topic


This Page