Functions#
callsign functions#
A callsign is an object identification used in logging. Normally, an object’s class name is enough. This is the default case for the callsign methods.
However, sometimes there are multiple objects of the same class which need to be distinguised between each other. For example when there are multiple http servers on different ports.
To handle this case, the class should have a callsign() method which returns the identifying string, such as the port.
- dls_utilpack.callsign.callsign(something, message=None)[source]#
Return the callsign of the object. If a message is given, then return a full message with the callsign prepended.
- Parameters:
- Returns:
callsign or callsign with message appended
- Return type:
If the something object has a callsign method, then this is used. Otherwise, use the object’s module and type name.
- dls_utilpack.callsign.callsign_html(the_object, message=None)[source]#
Return the callsign of the object wrapped in an html div with css class T_callsign.
See the callsign method for argument details.
Any html thus composed will have the callsign identifiers embedded in it.
The idea is that the css class normally be
display: none;
unless debugging.
datatype functions#
Validate strings according to expected data types. The allowed data types are denoted as string constants so these can be specified in string-based configuration such as yaml.
At time of writing, only integer datatypes are handled. It is intended to add more such as float, filename, dict, etc.
- class dls_utilpack.datatypes.Datatypes[source]#
Class with symbolic constants denoting the allowed data types.
- INTEGER = 'integer'#
- dls_utilpack.datatypes.verify(name, value, datatype)[source]#
Return the given value converted according to datatype.
- Parameters:
- Raises:
ValueError – if the value cannot be converted
RuntimeError – if the datatype is invalid
- Returns:
value from the conversion
- Return type:
Any
formatting functions#
version functions#
The version of the package can be returned as a single string or a dict.
When a string, it comes from the package __version__. When a dict, it also has __version__, as well as versions of other depdency packages.