Utility Functions

There are a few utility functions that you may find useful.


  • The getInfo function calls the settings script in S3MPython, which is driven by S3MPython.conf and prints version numbers and paths to the terminal.

  • Start a Python shell:

  • At the “>>>” python prompt enter this command:

    from S3MPython.examples import info

This function will be moved into utils.py in a future release.


Many of these functions are used to generate random, valid values for examples but you may find some useful in your own applications or demos.


Return an access control system list from a link. It can be a local file or a URL.
The file must be a plain text file.
Each access control tag must be on a separate line.
A default file is included with S3MPython if none is specified in S3MPython.conf


Return an etree object with registered namespaces.


Return a random pair of [latitude, longitude] values.

random_dtstr(start=None, end=None):

Return a random datetime string between start and end.

valid_cardinality(self, v):

A dictionary of valid cardinality values and the lower and upper values of the minimum and maximum
occurrences allowed.

The requested setting is then tested for a valid setting.

             minOccurs      maxOccurs

A Python value of 'None' equates to 'unbounded' or 'unlimited'.


Write the model to a XML Schema file wrapped with a root element and
namespace declarations.

xmlstub(model, example=False):

Write the model data to a XML file wrapped with a root element and
namespace declarations.

jsonstub(model, example=False):

Write the model data to a JSON file.