# Path: pytrainer/lib/singleton.py
# class Singleton (object):
#     def __new__(cls, *args, **kwargs): 
#         if not hasattr(cls, 'self'):
#             cls.self = object.__new__(cls)
#         return cls.self


from pytrainer.lib.singleton import Singleton
from gettext import gettext as _
        return 0.0
    else:
        _prts = pace_str.split(':')
        try:
            _p_min = int(_prts[0])
            _p_sec = int(_prts[1])
            return float( _p_min + (_p_sec/60.0))
        except:
            return 0.0

def float2pace(pace_flt):
    try:
        _pace = float(pace_flt)
    except:
        return ""
    _p_int = int(_pace)
    _p_frc = round((_pace - _p_int) * 60.0)
    if _p_frc == 60:
        _p_int += 1
        _p_frc = 0
    _pace_str = "%d:%02d" % (_p_int, _p_frc)
    return _pace_str

def pace_from_db(pace_db_float):
    """Helper function to generate real float from the mm.ss float representation in the database"""
    if not pace_db_float:
        return None
    _pace_str = '{:.2f}'.format(pace_db_float).replace('.', ':')
    return pace2float(_pace_str)


# Path: pytrainer/lib/singleton.py
# class Singleton (object):
#     def __new__(cls, *args, **kwargs): 
#         if not hasattr(cls, 'self'):
#             cls.self = object.__new__(cls)
#         return cls.self


# Path: pytrainer/lib/uc.py
from pytrainer.lib.singleton import Singleton
from gettext import gettext as _

        return 0.0
    else:
        _prts = pace_str.split(':')
        try:
            _p_min = int(_prts[0])
            _p_sec = int(_prts[1])
            return float( _p_min + (_p_sec/60.0))
        except:
            return 0.0

def float2pace(pace_flt):
    try:
        _pace = float(pace_flt)
    except:
        return ""
    _p_int = int(_pace)
    _p_frc = round((_pace - _p_int) * 60.0)
    if _p_frc == 60:
        _p_int += 1
        _p_frc = 0
    _pace_str = "%d:%02d" % (_p_int, _p_frc)
    return _pace_str

def pace_from_db(pace_db_float):
    """Helper function to generate real float from the mm.ss float representation in the database"""
    if not pace_db_float:
        return None
    _pace_str = '{:.2f}'.format(pace_db_float).replace('.', ':')
    return pace2float(_pace_str)


class UC(Singleton):