tools.printers package
Submodules
tools.printers.basicPrinter module
- class tools.printers.basicPrinter.BasicPrinter(output: str, filename: Union[None, str, PathLike], outputFormat: str = 'version3')[source]
Bases:
objectSuper class to handle the basic printing methods
- Variables
typeofexpectedvalues (str) – what type of evaluationType values to
print, apriori or posteriori :param output: one of: file, stdout
- addObj(obj) bool[source]
Adds object to the Printer.
- Parameters
obj – A object to be printed. Must match one of the types defined in formatObj
- Returns
True if the object has been added to the output. If the object does not belong to the pre-defined printing list toPrint, returns False.
- property filename: str
- flush() str[source]
Format the objects added to the output, print them to the screen or file and remove them from the printer.
- getTypeOfExpected() NllEvalType[source]
tiny convenience function for what evaluationType values to print, apriori (True) or posteriori
tools.printers.masterPrinter module
- class tools.printers.masterPrinter.MPrinter[source]
Bases:
objectMaster Printer class to handle the Printers (one printer/output type)
- addObj(obj)[source]
Adds the object to all its Printers:
- Parameters
obj – An object which can be handled by the Printers.
- flush() dict[source]
Ask all printers to write the output and clear their cache. If the printers return anything other than None, we pass it on.
- setOutPutFiles(filename: PathLike, silent: bool = False)[source]
Set the basename for the output files. Each printer will use this file name appended of the respective extension (i.e. .py for a python printer, .smodels for a summary printer,…)
- Parameters
filename – Input file name
silent – dont comment removing old files
tools.printers.printerRegistry module
- class tools.printers.printerRegistry.PrinterRegistry[source]
Bases:
objectFacility for all printers to register
- classmethod get(extension: str) Optional[BasicPrinter][source]
get the printer that serves a specific extension :returns: None, if no printer registered for that extension
- printers = {}
- classmethod register(printer: type[smodels.tools.printers.basicPrinter.BasicPrinter], extension: str) bool[source]
register this printer :param printer: Printer object to register :param extension: Extension this printer will be in charge of :returns: False if printer already exists (or other error), else True
tools.printers.pythonPrinter module
- class tools.printers.pythonPrinter.PyPrinter(output: str = 'stdout', filename: Optional[PathLike] = None, outputFormat: str = 'version3')[source]
Bases:
BasicPrinterPrinter class to handle the printing of one single pythonic output
- Variables
typeofexpectedvalues (str) – what type of evaluationType values to
print, apriori or posteriori :param output: one of: file, stdout
- flush() dict[source]
Write the python dictionaries generated by the object formatting to the defined output
- setOutPutFile(filename: PathLike, overwrite: bool = True, silent: bool = False)[source]
Set the basename for the python printer. The output filename will be filename.py. :param filename: Base filename :param overwrite: If True and the file already exists, it will be removed. :param silent: dont comment removing old files
tools.printers.slhaPrinter module
- class tools.printers.slhaPrinter.SLHAPrinter(output: str = 'file', filename: Optional[PathLike] = None, outputFormat: str = 'version3')[source]
Bases:
TxTPrinterPrinter class to handle the printing of slha format summary output. It uses the facilities of the TxTPrinter.
- Parameters
output – one of: file, stdout
- setOutPutFile(filename: PathLike, overwrite: bool = True, silent: bool = False)[source]
Set the basename for the text printer. The output filename will be filename.smodels. :param filename: Base filename :param overwrite: If True and the file already exists, it will be removed. :param silent: dont comment removing old files
tools.printers.summaryPrinter module
- class tools.printers.summaryPrinter.SummaryPrinter(output: str = 'stdout', filename: Optional[PathLike] = None, outputFormat: str = 'version3')[source]
Bases:
TxTPrinterPrinter class to handle the printing of one single summary output. It uses the facilities of the TxTPrinter.
- Parameters
output – one of: stdout, file
- setOutPutFile(filename: PathLike, overwrite: bool = True, silent: bool = False)[source]
Set the basename for the text printer. The output filename will be filename.smodels. :param filename: Base filename :param overwrite: If True and the file already exists, it will be removed. :param silent: dont comment removing old files
tools.printers.txtPrinter module
- class tools.printers.txtPrinter.TxTPrinter(output: str = 'stdout', filename: Optional[PathLike] = None, outputFormat: str = 'version3')[source]
Bases:
BasicPrinterPrinter class to handle the printing of one single text output
- Parameters
output – one of: file, stdout
- setOutPutFile(filename: PathLike, overwrite: bool = True, silent: bool = False)[source]
Set the basename for the text printer. The output filename will be filename.log.
- Parameters
filename – Base filename
overwrite – If True and the file already exists, it will be removed.
silent – dont comment removing old files
tools.printers.xmlPrinter module
- class tools.printers.xmlPrinter.XmlPrinter(output: str = 'stdout', filename: Optional[PathLike] = None, outputFormat: str = 'version3')[source]
Bases:
PyPrinterPrinter class to handle the printing of one single XML output
- Parameters
output – one of: file, stdout
- convertToElement(pyObj, parent, tag: str = '')[source]
Convert a python object (list,dict,string,…) to a nested XML element tree. :param pyObj: python object (list,dict,string…) :param parent: XML Element parent :param tag: tag for the daughter element
- flush()[source]
Get the python dictionaries generated by the object formatting to the defined output and convert to XML
- setOutPutFile(filename: PathLike, overwrite: bool = True, silent: bool = False)[source]
Set the basename for the text printer. The output filename will be filename.xml. :param filename: Base filename :param overwrite: If True and the file already exists, it will be removed. :param silent: dont comment removing old files