# Path: pytrainer/lib/fileUtils.py
# class fileUtils:
#     def __init__(self, filename, data):
#         self.filename = filename
#         self.data = data
# 
#     def run(self):
#         logging.debug('>>')
#         if self.data is not None:
#             logging.debug("Writing in %s " % self.filename) 
#             out = open(self.filename, 'w')
#             out.write(self.data)
#             out.close()
#         else:
#             logging.error("Nothing to write in %s" % self.filename)
#         logging.debug('<<')
# 
# Path: pytrainer/lib/uc.py
# class UC(Singleton):
#     """
#     When instantiated first time us is assigned to False.
#       us = False; user system is metric
#       us = True ; user system is imperial
#     """
# 
#     """ Units of physical quantities [metric, imperial] """
#     uc_units = {'distance' : [_('km'),_('mi')] , 'speed' : [_('km/h'), _('mph')],
#                 'pace' : [_('min/km'),_('min/mi')], 'height' : [_('m'), _('ft')],
#                 'weight': [_('kg'), _('lb')]}
# 
#     """ Conversion factors from metric to imperial, units as in uc_units """
#     uc_factors = {'distance' : 0.621371192, 'speed': 0.621371192, 'pace':1.609344,
#                   'height': 3.2808399, 'weight': 2.204624, 'none': 1}
# 
#     def __init__(self):
#         if not hasattr(self, 'us'):
#             self.us = False
# 
#     def __str__(self):
#         if self.us:
#             return 'imperial'
#         else:
#             return 'metric'
# 
#     def set_us(self, us):
#         if type(us) == bool:
#             self.us = us
# 
#     def get_unit(self, quantity):
#         if self.us:
#             return self.uc_units[quantity][1]
#         else:
#             return self.uc_units[quantity][0]
# 
#     unit_distance = property(lambda self: self.get_unit('distance') )
#     unit_speed = property( lambda self: self.get_unit('speed') )
#     unit_pace = property( lambda self: self.get_unit('pace') )
#     unit_height = property( lambda self: self.get_unit('height') )
#     unit_weight = property( lambda self: self.get_unit('weight') )
# 
#     def sys2usr(self, quantity, value):
#         """ Gives value of physical quantity (metric) in users system"""
#         try:
#             _val = float(value)
#         except (ValueError, TypeError):
#             return None
#         if self.us:
#             return _val * self.uc_factors[quantity]
#         else:
#             return _val
# 
#     def usr2sys(self, quantity, value):
#         """ Takes value (users system) and convert to metric (sys)"""
#         try:
#             _val = float(value)
#         except (ValueError, TypeError):
#             return None
#         if self.us:
#             return _val / self.uc_factors[quantity]
#         else:
#             return _val
# 
#     def usr2sys_str(self, quantity, val_str):
#         """ Similar to usr2sys but I/O is string representing a float.
#             Necessary until we have proper input validation in windowrecord.
#             Escpecially pace fix here should be eliminated asap.
#         """
#         if not self.us:
#             return val_str
# 
#         if quantity == 'pace':
#             _pace_dec = pace2float(val_str)
#             _pace_uc = self.usr2sys('pace', _pace_dec)
#             return float2pace(_pace_uc)
#         else:
#             try:
#                 _val = float(val_str)
#             except (ValueError, TypeError):
#                 return ""
#             return str( self.usr2sys(quantity, _val))
# 
#     """ Aliases for sys2usr """
#     def distance(self, value):
#         return self.sys2usr('distance', value)
#     def speed(self, value):
#         return self.sys2usr('speed', value)
#     def pace(self, value):
#         return self.sys2usr('pace', value)
#     def height(self, value):
#         return self.sys2usr('height', value)
#     def weight(self, value):
#         return self.sys2usr('weight', value)


import os
import re
import logging
import colorsys
import math
import traceback
    import html
    import cgi as html
import pytrainer.lib.points as Points
from pytrainer.lib.fileUtils import fileUtils
from pytrainer.lib.uc import UC
                            });\n
                polyline.setMap(map);\n''' % point[2]

                contenttemplate = [
                        "%s",
                        "Speed: %0.1f km/h",
                        "HR: %d bpm",
                        "Cadence: %d",
                ]

                content += '''
                    google.maps.event.addListener(polyline, 'click', function(event) {
                        var marker = new google.maps.InfoWindow({
                          position: event.latLng,
                          content: "%s"
                        });
                        marker.setMap(map);
                    });
                    ''' % contenttemplate[linetype] % point[1]
            pre = point

        content += '''
          }

        </script>
        </head>
        <body onload="initialize()">
          <div id="map_canvas" style="width:100%; height:100%"></div>
        </body>
        </html>'''

# Path: pytrainer/lib/fileUtils.py
# class fileUtils:
#     def __init__(self, filename, data):
#         self.filename = filename
#         self.data = data
# 
#     def run(self):
#         logging.debug('>>')
#         if self.data is not None:
#             logging.debug("Writing in %s " % self.filename) 
#             out = open(self.filename, 'w')
#             out.write(self.data)
#             out.close()
#         else:
#             logging.error("Nothing to write in %s" % self.filename)
#         logging.debug('<<')
# 
# Path: pytrainer/lib/uc.py
# class UC(Singleton):
#     """
#     When instantiated first time us is assigned to False.
#       us = False; user system is metric
#       us = True ; user system is imperial
#     """
# 
#     """ Units of physical quantities [metric, imperial] """
#     uc_units = {'distance' : [_('km'),_('mi')] , 'speed' : [_('km/h'), _('mph')],
#                 'pace' : [_('min/km'),_('min/mi')], 'height' : [_('m'), _('ft')],
#                 'weight': [_('kg'), _('lb')]}
# 
#     """ Conversion factors from metric to imperial, units as in uc_units """
#     uc_factors = {'distance' : 0.621371192, 'speed': 0.621371192, 'pace':1.609344,
#                   'height': 3.2808399, 'weight': 2.204624, 'none': 1}
# 
#     def __init__(self):
#         if not hasattr(self, 'us'):
#             self.us = False
# 
#     def __str__(self):
#         if self.us:
#             return 'imperial'
#         else:
#             return 'metric'
# 
#     def set_us(self, us):
#         if type(us) == bool:
#             self.us = us
# 
#     def get_unit(self, quantity):
#         if self.us:
#             return self.uc_units[quantity][1]
#         else:
#             return self.uc_units[quantity][0]
# 
#     unit_distance = property(lambda self: self.get_unit('distance') )
#     unit_speed = property( lambda self: self.get_unit('speed') )
#     unit_pace = property( lambda self: self.get_unit('pace') )
#     unit_height = property( lambda self: self.get_unit('height') )
#     unit_weight = property( lambda self: self.get_unit('weight') )
# 
#     def sys2usr(self, quantity, value):
#         """ Gives value of physical quantity (metric) in users system"""
#         try:
#             _val = float(value)
#         except (ValueError, TypeError):
#             return None
#         if self.us:
#             return _val * self.uc_factors[quantity]
#         else:
#             return _val
# 
#     def usr2sys(self, quantity, value):
#         """ Takes value (users system) and convert to metric (sys)"""
#         try:
#             _val = float(value)
#         except (ValueError, TypeError):
#             return None
#         if self.us:
#             return _val / self.uc_factors[quantity]
#         else:
#             return _val
# 
#     def usr2sys_str(self, quantity, val_str):
#         """ Similar to usr2sys but I/O is string representing a float.
#             Necessary until we have proper input validation in windowrecord.
#             Escpecially pace fix here should be eliminated asap.
#         """
#         if not self.us:
#             return val_str
# 
#         if quantity == 'pace':
#             _pace_dec = pace2float(val_str)
#             _pace_uc = self.usr2sys('pace', _pace_dec)
#             return float2pace(_pace_uc)
#         else:
#             try:
#                 _val = float(val_str)
#             except (ValueError, TypeError):
#                 return ""
#             return str( self.usr2sys(quantity, _val))
# 
#     """ Aliases for sys2usr """
#     def distance(self, value):
#         return self.sys2usr('distance', value)
#     def speed(self, value):
#         return self.sys2usr('speed', value)
#     def pace(self, value):
#         return self.sys2usr('pace', value)
#     def height(self, value):
#         return self.sys2usr('height', value)
#     def weight(self, value):
#         return self.sys2usr('weight', value)


# Path: pytrainer/extensions/googlemaps.py
import os
import re
import logging
import colorsys
import math
import traceback
    import html
    import cgi as html
import pytrainer.lib.points as Points
from pytrainer.lib.fileUtils import fileUtils
from pytrainer.lib.uc import UC

                            });\n
                polyline.setMap(map);\n''' % point[2]

                contenttemplate = [
                        "%s",
                        "Speed: %0.1f km/h",
                        "HR: %d bpm",
                        "Cadence: %d",
                ]

                content += '''
                    google.maps.event.addListener(polyline, 'click', function(event) {
                        var marker = new google.maps.InfoWindow({
                          position: event.latLng,
                          content: "%s"
                        });
                        marker.setMap(map);
                    });
                    ''' % contenttemplate[linetype] % point[1]
            pre = point

        content += '''
          }

        </script>
        </head>
        <body onload="initialize()">
          <div id="map_canvas" style="width:100%; height:100%"></div>
        </body>
        </html>'''

        file = fileUtils(self.htmlfile,content)