LCONF.transform

Overview

This module provides ready Transform and TypeConversion functions for casting.

Functions

LCONF.transform.lconf_to_bool(bool_str, extra_err_info)

Return python True or False for the input bool_str

Parameters:
  • bool_str – (str) must be any of: True, true, False, false
  • extra_err_info – (str) any additional info which will be printed if an error is raised: e.g line number, original line ect..
Returns:

(bool) conversion of the input int_str

Raises Err:

LCONF.transform.lconf_to_int(int_str, extra_err_info)

Return an integer of the input int_str

Parameters:
  • int_str – (str) string of a number must contain only digits plus optional a leading - (minus sign)
  • extra_err_info – (str) any additional info which will be printed if an error is raised: e.g line number, original line ect..
Returns:

(int)conversion of the input int_str

Raises Err:

LCONF.transform.lconf_to_float(number_str, extra_err_info)

Return a float of the input number_str

Parameters:
  • number_str

    (str) string of a number: must contain a valid number to be cast to python float()

    Python-Example

    Taken from the python documentation

    >>> float('+1.23')
    1.23
    >>> float('   -12345\n')
    -12345.0
    >>> float('1e-003')
    0.001
    >>> float('+1E6')
    1000000.0
    >>> float('-Infinity')
    -inf
    
  • extra_err_info – (str) any additional info which will be printed if an error is raised: e.g line number, original line ect..
Returns:

(float) conversion of the input number_str

Raises Err:

LCONF.transform.lconf_to_pathexpanduser(path_str, extra_err_info)

Return a path string if it starts with ~ expanduser else return it unchanged

Parameters:
  • path_str – (str) string of a path which must start with ~ or /
  • extra_err_info – (str) any additional info which will be printed if an error is raised: e.g line number, original line ect..
Returns:

(str) if input starts with ~ expanduser else return it unchanged

Raises Err:

LCONF.transform.lconf_to_datetime(date_str, extra_err_info)

Return a python datetime of the input date_str

Parameters:
  • date_str

    (str) string of a datetime: format:

    16 character long: YYYY-MM-DD hh:mm e.g. 2014-05-08 13:39 19 character long: YYYY-MM-DD hh:mm:ss e.g. 2014-05-08 13:39:00

  • extra_err_info – (str) any additional info which will be printed if an error is raised: e.g line number, original line ect..
Returns:

(datetime) conversion of the input date_str

Raises Err:

This Page