Example #1
0
 def __init__(self):
     self.servicebroker = None
     self.client = 0
     self.server = 0
     self.totalLogonSteps = 10
     self.bulkIDsToCfgNames = {}
     self.bulkEntries = []
     self.fmtMapping = {}
     self.fmtMapping[
         const.UE_DATETIME] = lambda value, value2: formatUtil.FmtDate(value
                                                                       )
     self.fmtMapping[
         const.UE_DATE] = lambda value, value2: formatUtil.FmtDate(
             value, 'ln')
     self.fmtMapping[
         const.UE_TIME] = lambda value, value2: formatUtil.FmtDate(
             value, 'nl')
     self.fmtMapping[
         const.UE_TIMESHRT] = lambda value, value2: formatUtil.FmtDate(
             value, 'ns')
     self.fmtMapping[
         const.UE_MSGARGS] = lambda value, value2: cfg.GetMessage(
             value[0], value[1]).text
     self.fmtMapping[
         const.UE_LOC] = lambda value, value2: self._GetLocalization(
             value, value2)
     self.fmtMapping[
         const.
         UE_MESSAGEID] = lambda value, value2: self._GetLocalizationByID(
             value, value2)
     self.fmtMapping[const.UE_LIST] = lambda value, value2: self._GetList(
         value, value2)
Example #2
0
def FormatValue(value, unitID=None):
    if value is None:
        return
    if unitID == dogmaConst.unitTime:
        return format.FmtDate(long(value * SEC), 'll')
    if unitID == dogmaConst.unitMilliseconds:
        return '%.2f' % (value / 1000.0)
    if unitID == dogmaConst.unitLength:
        return FmtDist2(value)
    if unitID == dogmaConst.unitHour:
        return format.FmtDate(long(value * HOUR), 'll')
    if unitID == dogmaConst.unitMoney:
        return format.FmtAmt(value)
    if unitID == dogmaConst.unitDatetime:
        return format.FmtDate(datetime.float_as_time(value))
    if unitID in (dogmaConst.unitInverseAbsolutePercent,
                  dogmaConst.unitInversedModifierPercent):
        value = float(round(1.0 - value, 6)) * 100
    elif unitID == dogmaConst.unitModifierPercent:
        value = abs(value * 100 - 100) * (-1 if value < 1.0 else 1)
    elif unitID == dogmaConst.unitAbsolutePercent:
        value *= 100
    if type(value) is str:
        value = eval(value)
    if unitID == dogmaConst.unitMass:
        return localization.formatters.FormatNumeric(value,
                                                     decimalPlaces=0,
                                                     useGrouping=True)
    if not isinstance(value, basestring) and abs(value - int(value)) < 1e-10:
        return format.FmtAmt(value)
    if unitID == dogmaConst.unitAttributePoints:
        return round(value, 1)
    if unitID == dogmaConst.unitMaxVelocity:
        return localization.formatters.FormatNumeric(value,
                                                     decimalPlaces=2,
                                                     useGrouping=True)
    if unitID in (dogmaConst.unitHitpoints, dogmaConst.unitVolume,
                  dogmaConst.unitInverseAbsolutePercent,
                  dogmaConst.unitInversedModifierPercent):
        if value < 1:
            significantDigits = 2 if unitID == dogmaConst.unitHitpoints else 3
            decimalPlaces = int(-math.ceil(math.log10(value)) +
                                significantDigits)
        else:
            decimalPlaces = 2
        return localization.formatters.FormatNumeric(
            value, decimalPlaces=decimalPlaces, useGrouping=True)
    return value
Example #3
0
 def GetReadingText(self, senderID, subject, created, message):
     sender = cfg.eveowners.Get(senderID)
     senderTypeID = sender.typeID
     if senderTypeID is not None and senderTypeID > 0:
         senderText = '<a href="showinfo:%(senderType)s//%(senderID)s">%(senderName)s</a>' % {
             'senderType': senderTypeID,
             'senderID': senderID,
             'senderName': sender.name
         }
     else:
         senderText = sender.name
     date = fmtUtils.FmtDate(created, 'ls')
     newmsgText = localization.GetByLabel('UI/Mail/NotificationText',
                                          subject=subject,
                                          sender=senderText,
                                          date=date,
                                          body=message)
     return newmsgText