Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
utils.backend_utils.BackendUtils Class Reference

This class contains a collection of static methods for various backend-ish uses. More...

Inheritance diagram for utils.backend_utils.BackendUtils:

Static Public Member Functions

def setup_logging
 Sets up logging for an application. More...
 
def get_word_count
 Counts the number of words in a string. More...
 
def break_time
 Spilts a given time duration (expressed in seconds) into hours, minutes, and seconds. More...
 
def get_time_str
 Creates a formatted string (suitable for display) from a given time duration (expressed in seconds) More...
 
def time_str_to_float
 
def pad_num_str
 Accepts a string (containing only digits), and prefixes it with a zero if it is < 10. More...
 
def is_float
 Checks if a given string contains a float. More...
 

Static Private Member Functions

def _get_date_val
 Converts a date (string) to an integer that's suitable for comparison. More...
 

Detailed Description

This class contains a collection of static methods for various backend-ish uses.

This class should never be instantiated. Similar UI tools should go in the UIUtils (utils.ui_utils.py) class.

Definition at line 10 of file backend_utils.py.

Member Function Documentation

def utils.backend_utils.BackendUtils._get_date_val (   date_str)
staticprivate

Converts a date (string) to an integer that's suitable for comparison.

Parameters
date_str(string) date string in the form 'mm/dd/yyyy', followed by an optional space and 'hh:mm'
Returns
(int) an integer representing this date - safe to use for comparing dates

Definition at line 103 of file backend_utils.py.

def utils.backend_utils.BackendUtils.break_time (   total_sec)
static

Spilts a given time duration (expressed in seconds) into hours, minutes, and seconds.

Parameters
total_sec(int/float) an amount of time, expressed in seconds
Returns
(int, int, int/float) three values representing hours, minutes (< 60), seconds (< 60)

Definition at line 39 of file backend_utils.py.

def utils.backend_utils.BackendUtils.get_time_str (   total_sec,
  pad_hour_min = True,
  show_hours = True,
  show_decimals = True 
)
static

Creates a formatted string (suitable for display) from a given time duration (expressed in seconds)

Parameters
total_sec(int/float) an amount of time, expressed in seconds
pad_hour_min(boolean=True) Set whether or not to zero-pad hours and minutes placeholders (seconds are always zero-padded)
show_hours(boolean=True) Set whether or not to show hours placeholder
show_decimals(boolean=True) Set whether or not to show seconds decimal places (if not, seconds are truncated - not rounded!)
Returns
(string) a string in the format 'hh:mm:ss.ss'

Definition at line 58 of file backend_utils.py.

def utils.backend_utils.BackendUtils.get_word_count (   text)
static

Counts the number of words in a string.

Parameters
text(string) the string to operate upon.
Returns
(int) number of words in the string. Hyphens and apostrophies will be converted to spaces before the count is performed, so contractions or hyphenated expressions will count as multiple words (e.g. "can't" => "can t" = 2 words).

Definition at line 29 of file backend_utils.py.

def utils.backend_utils.BackendUtils.is_float (   num_str)
static

Checks if a given string contains a float.

Parameters
num_str(string) the string to check
Returns
(boolean) True if num_str contains a float, False otherwise

Definition at line 118 of file backend_utils.py.

def utils.backend_utils.BackendUtils.pad_num_str (   num_str)
static

Accepts a string (containing only digits), and prefixes it with a zero if it is < 10.

Parameters
num_str(string) an integer in string form
Returns
(string) if num_str contains an integer that is less than 10, returns a new string that is num_str prefixed with a zero; otherwise returns num_str

Definition at line 96 of file backend_utils.py.

def utils.backend_utils.BackendUtils.setup_logging (   full_log_filename)
static

Sets up logging for an application.

Parameters
full_log_filename(string) Full path to the log file to use - if the file does not exist, it will be created.

Definition at line 14 of file backend_utils.py.

def utils.backend_utils.BackendUtils.time_str_to_float (   time_str)
static

Definition at line 80 of file backend_utils.py.


The documentation for this class was generated from the following file: