Example #1
0
def formatFloat(f, decimal_places=2):
    """ return a float with thousand commas
    and two decimal places if any. """
    try:
        assert type(f) is FloatType or type(f) is IntType, \
               "parameter f is not float or int"
    except AssertionError:
        f = float(f)

    if str(int(f))!=str(f): # try if f==1.1 but not if f==1
        f= round(f, decimal_places)
        _fmt = "%."+str(decimal_places)+"f"
        f = _fmt%f

    f = thousands_commas(f)

    return f
Example #2
0
 def summary_length(self):
     length = self._getBatchObj().sequence_length
     return length and thousands_commas(length) or ''
Example #3
0
 def summary_length(self):
     length = self._getBatchObj().sequence_length
     return length and thousands_commas(length) or ''
Example #4
0
    if k in ('review_state', 'Title', 'Subject', 'Description', 'portal_type',
             'listCreators'):
        if same_type(v, []):
            v = filter(None, v)
        if not v:
            del kw[k]
    elif k in ('created', ):
        if v['query'] == epoch and v['range'] == 'min':
            del kw[k]
        else:
            # work around problems with DateTime in records
            kw[k] = v.copy()
    elif k in ('go', 'go.x', 'go.y', 'b_start'):
        del kw[k]
items = ctool.searchResults(kw)
batch_obj = Batch(items, 25, b_start, orphan=1)
length = batch_obj.sequence_length
summary = {
    'length': length and thousands_commas(length) or '',
    'type': (length == 1) and _('item') or _('items'),
    'match': kw.get('SearchableText')
}
navigation = context.getBatchNavigation(batch_obj, target, **kw)
options['batch'] = {
    'summary': summary,
    'listItemBrains': batch_obj,
    'navigation': navigation
}

return context.search_results_template(**options)
Example #5
0
            del kw[k]
    elif k in ('created',):
        if v['query'] == epoch and v['range'] == 'min':
            del kw[k]
        else:
            # work around problems with DateTime in records
            kw[k] = v.copy()
    elif k in ('go', 'go.x', 'go.y', 'b_start'):
            del kw[k]
items = ctool.searchResults(kw)
batch_obj = Batch(items, 25, b_start, orphan=1)

items = [ {'description': item.Description,
           'icon': item.getIcon,
           'title': item.Title,
           'type': item.Type,
           'date': item.Date,
           'url': item.getURL()+'/view'}
          for item in batch_obj ]

length = batch_obj.sequence_length
summary = { 'length': length and thousands_commas(length) or '',
            'type': (length == 1) and _(u'item') or _(u'items'),
            'match': kw.get('SearchableText') }
navigation = context.getBatchNavigation(batch_obj, target, **kw)
options['batch'] = { 'summary': summary,
                     'listItemInfos': tuple(items),
                     'navigation': navigation }

return context.search_results_template(**decode(options, script))