riverine.printing
=================

.. py:module:: riverine.printing


Attributes
----------

.. autoapisummary::

   riverine.printing.cell_with_border_css_class
   riverine.printing.html_with_borders_tablefmt
   riverine.printing._ALL_TABLEFMTS
   riverine.printing._ALL_TABLEFMTS_NAMES
   riverine.printing._SUPPORTED_TABLEFMTS_TITLE
   riverine.printing._NL


Classes
-------

.. autoapisummary::

   riverine.printing.MixLine


Functions
---------

.. autoapisummary::

   riverine.printing.emphasize
   riverine.printing._format_error_span
   riverine.printing._html_row_with_attrs
   riverine.printing._formatter
   riverine.printing._format_title
   riverine.printing._format_errors
   riverine.printing._format_location
   riverine.printing.gel_table


Module Contents
---------------

.. py:function:: emphasize(text: str, tablefmt: str | tabulate.TableFormat, strong: bool = False) -> str

   Emphasizes `text` according to `tablefmt`, e.g., for Markdown (e.g., `tablefmt` = `'pipe'`),
   surrounds with pair of *'s; if `strong` is True, with double *'s. For `tablefmt` = `'html'`,
   uses ``<emph>`` or ``<strong>``.

   :param text: text to emphasize
   :param tablefmt: format in which to add emphasis markup

   :rtype: emphasized version of `text`


.. py:function:: _format_error_span(out, tablefmt)

.. py:data:: cell_with_border_css_class
   :value: 'cell-with-border'


.. py:function:: _html_row_with_attrs(celltag: str, cell_values: riverine.units.Sequence[str], colwidths: riverine.units.Sequence[int], colaligns: riverine.units.Sequence[str]) -> str

.. py:data:: html_with_borders_tablefmt

   Pass this as the parameter `tablefmt` in any method that accepts that parameter to have the table
   be an HTML table with borders around each cell.

.. py:data:: _ALL_TABLEFMTS

.. py:data:: _ALL_TABLEFMTS_NAMES
   :type:  list[str]

.. py:data:: _SUPPORTED_TABLEFMTS_TITLE

.. py:data:: _NL
   :type:  dict[riverine.units.Union[str, tabulate.TableFormat], str]

.. py:function:: _formatter(x: float | str | list[str] | riverine.units.DecimalQuantity | None, italic: bool = False, tablefmt: str | tabulate.TableFormat = 'pipe', splits: list = []) -> str

.. py:class:: MixLine

   Class for handling a line of a (processed) mix recipe.

   Each line should represent a single step, or series of similar steps (same volume per substep)
   in the mixing process.

   :param names: A list of component names.  For a single step, use [name].
   :param source_conc: The source concentration; may not be provided (will be left blank), or be a descriptive string.
   :param dest_conc: The destination/target concentration; may not be provided (will be left blank), or be a descriptive string.
   :param total_tx_vol: The total volume added to the mix by the step.  If zero, the amount will still be included in tables.
                        If None, the amount will be blank.  If provided, and the line is not fake, the value must be correct
                        and interpretable for calculations involving the mix.
   :param number: The number of components added / subste
   :param each_tx_vol: The volume per component / substep.  May be omitted, or a descriptive string.
   :param plate: The plate name for the mix, a descriptive string for location / source type (eg, "tube") or None (omitted).
                 A single MixLine, at present, should not involve multiple plates.
   :param wells: A list of wells for the components in a plate.  If the components are not in a plate, this must be an
                 empty list.  This *does not* parse strings; wells must be provided as WellPos instances.
   :param note: A note to add for the line
   :param fake: Denotes that the line is not a real step, eg, for a summary/total information line.  The line
                will be distinguished in some way in tables (eg, italics) and will not be included in calculations.


   .. py:attribute:: names
      :type:  list[str]


   .. py:attribute:: source_conc
      :type:  riverine.units.DecimalQuantity | str | None
      :value: None



   .. py:attribute:: dest_conc
      :type:  riverine.units.DecimalQuantity | str | None
      :value: None



   .. py:attribute:: total_tx_vol
      :type:  riverine.units.DecimalQuantity


   .. py:attribute:: number
      :type:  int
      :value: 1



   .. py:attribute:: each_tx_vol
      :type:  riverine.units.DecimalQuantity


   .. py:attribute:: plate
      :type:  str
      :value: ''



   .. py:attribute:: wells
      :type:  list[riverine.locations.WellPos]


   .. py:attribute:: note
      :type:  str | None
      :value: None



   .. py:attribute:: fake
      :type:  bool
      :value: False



   .. py:method:: __attrs_post_init__()


   .. py:method:: _check_wells(_: str, v: Any) -> None


   .. py:method:: _check_names(_: str, v: Any) -> None


   .. py:method:: location(tablefmt: str | tabulate.TableFormat = 'pipe', split: bool = True) -> tuple[str | list[str], list[int]]

      A formatted string (according to `tablefmt`) for the location of the component/components.



   .. py:method:: toline(incea: bool, tablefmt: str | tabulate.TableFormat = 'pipe') -> riverine.units.Sequence[str]


.. py:function:: _format_title(raw_title: str, level: int, tablefmt: str | tabulate.TableFormat) -> str

.. py:function:: _format_errors(errors: list[riverine.units.VolumeError], tablefmt: tabulate.TableFormat | str) -> str

.. py:function:: _format_location(loc: tuple[str | None, riverine.locations.WellPos | None]) -> str

.. py:function:: gel_table(sample_names: Iterable[str], num_lanes: int | None = None, tablefmt: tabulate.TableFormat | str = 'pipe') -> str

   Return Markdown table representing which lanes to put samples into for a gel.

   :param sample_names: names of samples to go into lanes of the gel
   :param num_lanes: total number of lanes in the gel; if not specified, assumed to be number of elements in
                     `sample_names`
   :param tablefmt: The output format for the table. (See documentation for table formats in tabulate package.)

   :rtype: Markdown table representing which lanes to put samples into for a gel


