def _mk_label(mapper, show_operations, show_attributes, show_datatypes, show_inherited, bordersize):
html = '<<TABLE CELLSPACING="0" CELLPADDING="1" BORDER="0" CELLBORDER="%d" BALIGN="LEFT"><TR><TD><FONT POINT-SIZE="10">%s</FONT></TD></TR>' % (bordersize, mapper.class_.__name__)
def format_col(col):
colstr = '+%s' % (col.name)
if show_datatypes:
colstr += ' : %s' % (col.type.__class__.__name__)
return colstr
if show_attributes:
if not show_inherited:
cols = [c for c in mapper.columns if c.table == mapper.tables[0]]
else:
cols = mapper.columns
html += '<TR><TD ALIGN="LEFT">%s</TD></TR>' % '<BR ALIGN="LEFT"/>'.join(format_col(col) for col in cols)
else:
[format_col(col) for col in sorted(mapper.columns, key=lambda col:not col.primary_key)]
if show_operations:
html += '<TR><TD ALIGN="LEFT">%s</TD></TR>' % '<BR ALIGN="LEFT"/>'.join(
'%s(%s)' % (name,", ".join(default is _mk_label and ("%s") % arg or ("%s=%s" % (arg,repr(default))) for default,arg in
zip((func.__defaults__ and len(func.__code__.co_varnames)-1-(len(func.__defaults__) or 0) or func.__code__.co_argcount-1)*[_mk_label]+list(func.__defaults__ or []), func.__code__.co_varnames[1:])
))
for name,func in list(mapper.class_.__dict__.items()) if isinstance(func, types.FunctionType) and func.__module__ == mapper.class_.__module__
)
html+= '</TABLE>>'
return html
sqlalchemy_schemadisplay.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录