本文整理汇总了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: