schrodinger.infra.mmcheck module¶
- schrodinger.infra.mmcheck.wrap_module(module_dict, return_codes, ignored_functions, failure_dict, inserted_module_globals=None)¶
Create wrappers for all of the mmlibs and place them into the module’s global namespace.
- Parameters
return_codes (dict) – Dict of ReturnCode objects, as generated by generate_return_codes
ignored_functions (iterable of strings) – are functions that are created by swig which don’t match
failure_dict (dict) – error code returned if the function encounters an error, when it is not covered by the normal return_codes dict
- exception schrodinger.infra.mmcheck.MmException(wrapped_function, args, rc)¶
Bases:
Exception
An exception class that specifically indicates the failure of an mmlibs call. The underlying value of the error code returned by the mmlib function can be retrieved through the ‘rc’ attribute of the exception. The name of the return code can be retrieved through the ‘rc_name’ attribute of the exception.
- __init__(wrapped_function, args, rc)¶
Initialize with the wrapped function, arguments used, and the return code.
- class schrodinger.infra.mmcheck.ReturnCode¶
Bases:
object
A class to hold special return code values and translate return code values into names.
- ok_pattern = re.compile('^[A-Z][A-Z0-9]*_OK$')¶
- error_pattern = re.compile('^[A-Z][A-Z0-9]*_(ERR(OR)?|BUMMER)$')¶
- __init__()¶
- add_code(module, name, value=None)¶
Add a code name and value to the object. If value is not provided, look it up in the pymmlibs module from the name given.
- get_name(value)¶
Return the name associated with the value.
- schrodinger.infra.mmcheck.generate_return_code_dict(global_dict, code_lists)¶
Set up a dictionary of ReturnCode objects, indexed by the mmlib prefix names. This dictionary is used to translate error codes into names so errors make more sense to the humans reading the error message.
- Parameters
global_dict – globals() dict of the module with these return codes
code_lists (list) –
Each member of the code_lists list is a list of the names of the return codes for a specific mmlib. Please keep the list sorted by mmlib prefix so it is easy to find the proper place to add new return codes.
The return codes are listed explicitly to speed the import of this module.