本文整理匯總了Python中s3validators.IS_NUMBER類的典型用法代碼示例。如果您正苦於以下問題:Python IS_NUMBER類的具體用法?Python IS_NUMBER怎麽用?Python IS_NUMBER使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IS_NUMBER類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _totals
def _totals(values, layers, append=None):
"""
Get the totals of a row/column/report
@param values: the values dictionary
@param layers: the layers
@param append: callback to collect the totals for JSON data
(currently only collects the first layer)
"""
totals = []
for layer in layers:
f, m = layer
value = values[layer]
if m == "list":
value = value and len(value) or 0
if not len(totals) and append is not None:
append(value)
totals.append(IS_NUMBER.represent(value))
totals = " / ".join(totals)
return totals
示例2: __init__
#.........這裏部分代碼省略.........
cell_vals = Storage()
for i in xrange(numrows):
# Initialize row
_class = i % 2 and "odd" or "even"
tr = TR(_class=_class)
add_cell = tr.append
# Row header
row = rvals[i]
v = represent(rows, row.value)
add_row_title(s3_truncate(unicode(v)))
rowhdr = TD(v)
add_cell(rowhdr)
# Result cells
for j in xrange(numcols):
cell = cells[i][j]
vals = []
cell_ids = []
add_value = vals.append
for layer_idx, layer in enumerate(layers):
f, m = layer
value = cell[layer]
if m == "list":
if isinstance(value, list):
l = [represent(f, v, d="-") for v in value]
elif value is None:
l = ["-"]
else:
if type(value) in (int, float):
l = IS_NUMBER.represent(value)
else:
l = unicode(value)
#add_value(", ".join(l))
add_value(UL([LI(v) for v in l]))
else:
if type(value) in (int, float):
add_value(IS_NUMBER.represent(value))
else:
add_value(unicode(value))
# hold the references
layer_ids = []
# get previous lookup values for this layer
layer_values = cell_lookup_table.get(layer_idx, {})
if m == "count":
rfield = rfields[f]
field = rfield.field
colname = rfield.colname
has_fk = field is not None and s3_has_foreign_key(field)
for id in cell.records:
# cell.records == [#, #, #]
record = report.records[id]
try:
fvalue = record[colname]
except AttributeError:
fvalue = None
if fvalue is not None:
if has_fk:
if type(fvalue) is not list:
示例3: __init__
#.........這裏部分代碼省略.........
cells = report.cell
rvals = report.row
for i in xrange(numrows):
# Initialize row
_class = i % 2 and "odd" or "even"
tr = TR(_class=_class)
add_cell = tr.append
# Row header
row = rvals[i]
v = represent(rows, row.value)
add_row_title(s3_truncate(unicode(v)))
rowhdr = TD(v)
add_cell(rowhdr)
# Result cells
for j in xrange(numcols):
cell = cells[i][j]
vals = []
cell_ids = []
add_value = vals.append
for layer_idx, layer in enumerate(layers):
f, m = layer
value = cell[layer]
if m == "list":
if isinstance(value, list):
l = [represent(f, v, d="-") for v in value]
elif value is None:
l = "-"
else:
if type(value) in (int, float):
l = IS_NUMBER.represent(value)
else:
l = unicode(value)
add_value(", ".join(l))
else:
if type(value) in (int, float):
add_value(IS_NUMBER.represent(value))
else:
add_value(unicode(value))
# hold the references
layer_ids = []
# get previous lookup values for this layer
layer_values = cell_lookup_table.get(layer_idx, {})
if m == "count":
rfield = rfields[f]
field = rfield.field
colname = rfield.colname
has_fk = field is not None and s3_has_foreign_key(field)
for id in cell.records:
# cell.records == [#, #, #]
record = report.records[id]
try:
fvalue = record[colname]
except AttributeError:
fvalue = None
if fvalue is not None:
if has_fk:
if not isinstance(fvalue, list):
fvalue = [fvalue]
示例4: __init__
#.........這裏部分代碼省略.........
# Initialize row
_class = i % 2 and "odd" or "even"
tr = TR(_class=_class)
add_cell = tr.append
# Row header
row = rows_list[i][0]
v = row["text"]
add_row_title(s3_truncate(unicode(v)))
rowhdr = TD(v)
add_cell(rowhdr)
row_cells = rows_list[i][1]
# Result cells
for j in xrange(numcols):
cell_idx = cols_list[j][1]
cell = row_cells[cell_idx]
vals = []
cell_ids = []
add_value = vals.append
for layer_idx, layer in enumerate(layers):
f, m = layer
value = cell[layer]
if m == "list":
if isinstance(value, list):
l = [represent(f, v, d="-") for v in value]
elif value is None:
l = ["-"]
else:
if type(value) in (int, float):
l = IS_NUMBER.represent(value)
else:
l = unicode(value)
#add_value(", ".join(l))
add_value(UL([LI(v) for v in l]))
else:
if type(value) in (int, float):
add_value(IS_NUMBER.represent(value))
else:
add_value(unicode(value))
layer_ids = []
layer_values = cell_lookup_table.get(layer_idx, {})
if m == "count":
rfield = rfields[f]
field = rfield.field
colname = rfield.colname
has_fk = field is not None and s3_has_foreign_key(field)
for id in cell.records:
record = report.records[id]
try:
fvalue = record[colname]
except AttributeError:
fvalue = None
if fvalue is not None:
if has_fk:
if type(fvalue) is not list:
fvalue = [fvalue]
# list of foreign keys
for fk in fvalue: