SLiCAPhtml.py

SLiCAP module with HTML functions.

This module is imported by SLiCAPyacc.py

HTMLfoot(indexFile)

Returns html page footer with link to ‘indexFile’.

Parameters

indexFile (str) – name of ther hml index file to which a link must be placed in the footer.

Returns

html: HTML footer with link to ‘indexFile’

Return type

str

HTMLhead(pageTitle)

Returns the html head for a new html page.

Parameters

pageTitle (str) – Title of the page

Returns

html: Page head for a html page

Return type

str

class Label(name, typ, page, text)

Prototype HTML label

name

Label name (str)

Automatically set by HTML functions that have a label as parameter.

page

Name of the page on which the label is placed (str)

Automatically set by HTML functions that have a label as parameter.

text

Label text (str) to be placed with the label when using links2html. If the label is attached to a figure, this text is the figure caption.

type

Type of label (str)

Automatically set by HTML functions that have a label as parameter. Used by SLiCALhtml.links2html() for sorting the links. Value can be: ‘headings’, ‘data’, ‘fig’, ‘eqn’ or ‘analysis’.

checkNumeric(exprList)

Returns True if all entries in the list ‘exprList’ are numeric.

:param exprList; List with numbers and/or expressions :type exprList: list

Returns

True is all entries in ‘exprList’ are numeric.

Return type

Bool

coeffsTransfer2html(transferCoeffs, label='', labelText='')

Displays the coefficients of the numerator and the denominator of a transfer function on the active html page.

csv2html(fileName, label='', separator=',', caption='')

Displays the contents of a csv file as a table on the active HTML page.

Parameters
  • fileName (str) – Name of the csv file file

  • label (str) – ID of the label assigned to this table.

  • separator (str) – Field separator for this csv file; defaults to ‘,’.

  • caption (str) – Caption for this table.

Returns

html: HTML string that will be placed on the page.

Return type

str

dcVar2html(instObj, label='', labelText='')

Displays the reults of a dcVAr analysis on the active html page.

Not implemented with parameter stepping.

Parameters
  • instObj (SLiCAP.protos.allResults) – Results of an instruction with data type ‘dcvar’.

  • label (str) – ID of the label assigned to these tables; defaults to ‘’.

  • labelText (str) – Label text to be displayed by links2html(); defaults to ‘’

Returns

html: HTML string that will be placed on the page.

Return type

str

elementData2html(circuitObject, label='', caption='')

Displays a table with element data on the active html page:

  • refDes

  • nodes

  • referenced elements

  • element parameters with symbolic and numeric values

Parameters
  • circuitObject (SLiCAPprotos.circuit) – SLiCAP circuit object of which the element data will be displayed on the HTML page.

  • label (str) – Label that will be assigned to this table.

  • caption (str) – Caption that will be placed with this table.

Returns

html: HTML string that will be placed on the page.

Return type

str

eqn2html(arg1, arg2, units='', label='', labelText='')

Displays an equation on the active HTML page’.

Parameters
  • arg1 (str, sympy.Symbol, sympy.Expr) – left hand side of the equation

  • arg2 (str, sympy.Symbol, sympy.Expr) – right hand side of the equation

  • label (str) – ID of the label assigned to this equation; defaults to ‘’.

  • labelText (str) – Label text to be displayed by links2html(); defaults to ‘’

Returns

html: HTML string that will be placed on the page.

Return type

str

expr2html(expr, units='')

Inline display of an expression optional with units.

Parameters
  • expr (sympy.Expr) – Expression

  • units (str) – Units for this expression, defaults to ‘’.

Returns

html: HTML string that will be placed on the page.

Return type

str

fig2html(figureObject, width, label='', caption='')

Copies the image file to the ‘img.’ subdirectory of the ‘html/’ directory set by HTMLPATH in SLiCAPini.py and creates a link to this file on the active html page.

file2html(fileName)

Writes the contents of a file to the active html page.

Parameters

fileName (str) – Name of the file (relative to ini.textPath)

Returns

html code

Return type

str

head2html(headText, label='')

Places a level 2 heading on the active HTML page.

Parameters
  • headText (str) – header text

  • label (str) – ID of a labelthat can be assigned to this page.

Returns

HTML string of this header

Return type

str

head3html(headText, label='')

Places a level 3 heading on the active HTML page.

Parameters
  • headText (str) – header text

  • label (str) – ID of a labelthat can be assigned to this page.

Returns

HTML string of this header

Return type

str

href(label, fileName='')

Returns the html code for a jump to a label ‘labelName’. This label can be on any page. If referring backwards ‘fileName’ can be detected automatically. When referring forward ‘fileName’ must be the name of the file that will be created later. Run a project 2 times without closing it after the first run, automaitcally detects all labels.

htmlElValue(instr, elName)

Returns code for inline display of value of element ‘elName’ from instruction ‘instr’. If instr.simType == ‘numeric’ it applies a full substitution of all other parameter definitions.

Parameters
Returns

html code for the element value

Return type

string

Returns the html code for placing a link on an html page with text2html().

Parameters

address (str) – link address

Returns

html code

Return type

str

htmlPage(pageTitle, index=False, label='')

Creates an HTML page with the title in the title bar.

If index==True the page will be used as new index page, else a link to this page will be placed on the current index page.

:param pageTitle:Title of the page. :type param: str :param index: True or False :type index: Bool :param label: ID of a labelthat can be assigned to this page. :type label: str

Example

>>> htmlPage('Circuit data')
htmlParValue(instr, parName)

Returns code for inline display of parameter ‘parName’ from instruction ‘instr’. If instr.simType == ‘numeric’ it applies a full substitution of all other parameter definitions.

Parameters
Returns

html code for the parameter value

Return type

string

img2html(fileName, width, label='', caption='')

Places an image from file ‘fileName’ on the active html page.

Copies the image file to the ‘img.’ subdirectory of the ‘html/’ directory and creates a link to this file on the active html page.

Parameters
  • fileName (str) – Name of the image file

  • width (int) – With of the image in pixels

  • label (str) – ID of the label to be assigned to this image, defaults to ‘’.

  • caption (str) – Caption for this image; defaults to ‘’.

Returns

file path for this image.

Return type

str

insertHTML(fileName, htmlInsert)

Inserts html in the file specified by ‘fileName’ at the location of the string ‘HTMLINSERT’.

Parameters
  • fileName (str) – name of the file

  • htmlInsert (str) – HTML that must be inserted in this file

lib2html(fileName, label='')

Places the contents of the library file ‘fileName’ on the active HTML page.

Parameters
  • fileName (str) – Name of the library file

  • label (str) – Label ID for this object.

Returns

html: HTML string that will be placed on the page.

Return type

str

links2html()

Returns the HTML code for placing links to all labeled HTML objects.

Links will be grouped as follows:

  1. Links to headings

  2. Links to circuit data and imported tables

  3. Links to figures

  4. Links to equations

  5. Links to analysis results (from noise2html, pz2html, etc.)

Returns

html: HTML string that will be placed on the page.

Return type

str

matrices2html(instrObj, label='', labelText='')

Displays the MNA equation on the active HTML page.

Parameters
  • instrObj (SLiCAPprotos.allResults) – Results of instruction with data type matrix.

  • label (str) – ID of the label assigned to this equation; defaults to ‘’.

  • labelText (str) – Label text to be displayed by links2html(); defaults to ‘’

Returns

html: HTML string that will be placed on the page.

Return type

str

netlist2html(fileName, label='')

Places the netlist of the circuit file ‘fileName’ on the active HTML page.

Parameters
  • fileName (str) – Name of the netlist file

  • label (str) – Label ID for this object.

Returns

html: HTML string that will be placed on the page.

Return type

str

noise2html(instObj, label='', labelText='')

Displays the reults of a noise analysis on the active html page.

Not implemented with parameter stepping.

Parameters
  • instObj (SLiCAP.protos.allResults) – Results of an instruction with data type ‘noise’.

  • label (str) – ID of the label assigned to these tables; defaults to ‘’.

  • labelText (str) – Label text to be displayed by links2html(); defaults to ‘’

Returns

html: HTML string that will be placed on the page.

Return type

str

params2html(circuitObject, label='', caption='')

Displays a table with circuit parameters, their definitions and numeric values on the actibe htmal page.

Parameters
  • circuitObject (SLiCAPprotos.circuit) – SLiCAP circuit object of which the element data will be displayed on the HTML page.

  • label (str) – Label that will be assigned to this table.

  • caption (str) – Caption that will be placed with this table.

Returns

html: HTML string that will be placed on the page.

Return type

str

pz2html(instObj, label='', labelText='')

Displays the DC transfer, and tables with poles and zeros on the active HTML page.

Not (yet) implemented with parameter stepping.

Parameters
  • instObj (SLiCAP.protos.allResults) – Results of an instruction with data type ‘poles’, ‘zeros’ or ‘pz’.

  • label (str) – ID of the label assigned to these tables; defaults to ‘’.

  • labelText (str) – Label text to be displayed by links2html(); defaults to ‘’

Returns

html: HTML string that will be placed on the page.

Return type

str

readFile(fileName)

Returns the contents of a file as a string.

Parameters

fileName (str) – Name of the file

Returns

txt: contents of the file.

Return type

str

startHTML(projectName)

Creates main project index page.

Param

projectName: Name of the project.

stepArray2html(stepVars, stepArray)

Displays the step array on the active HTML page.

Returns

html: HTML string that will be placed on the page.

Return type

str

text2html(txt)

Places txt on the active HTML page. :param txt: Text to be placed on the HTML page :type txt: str :return: html: HTML string placed on the page :rtype: str

writeFile(fileName, txt)

Writes a text string to a file.

Parameters
  • fileName (str) – Name of the file

  • txt (str) – Text to be written to the file.