def helphtml(obj,*aos): txt='' import pydoc,re if aos: aos=flat(obj,aos,noNone=True) for i in aos: #TODO txt+=re.sub('.\b', '', pydoc.render_doc(i,'%s')) txt+='\n==============%s=======================\n'%ct(aos) else:txt=re.sub('.\b', '', pydoc.render_doc(obj,'%s')) # txt=txt.replace(txthtml[1],txthtml[1][:1]+'!!!qgb-padding!!!'+txthtml[1][1:]) # txt=txthtml[0]+txt+txthtml[1] # msgbox(txt[txt.find(b'\x08'):]) # repl() # exit() file='Uhelp_obj.txt' try: import T if obj:file=T.filename(getObjName(obj))+'.txt' elif aos:file=T.filename(getObjName(aos[0]))+'..%s.txt'%len(aos) except:pass with open(file,'w') as f: f.write(txt) # write(file,txt) globals()['browser'](file)
def shtml(txt,file='',browser=True): import T,pprint,F if file=='' and type(txt) is not str: try:file=T.filename(T.max(txt.__str__(),txt.__repr__(),txt.__name__)[:19]) except:pass # if type(txt) in (dict,list): txt=pprint.pformat(txt) # if len(txt)==0:return # s=[] # for i in txt.keys(): # s.append(T.string(i)+' : '+T.string(txt[i])+'\n') # txt=T.listToStr(s) # if len(file)<1:file=T.filename(getObjName(txt)+stime())[:19] if not file.lower().endswith('.txt'):file+='.txt' F.write(file,txt) # f=open(file+'.txt','a') # rm(f.name) # txt=txt.replace(txthtml[1],txthtml[1][:1]+'!!!qgb-padding!!!'+txthtml[1][1:]) # f.write(txthtml[0]) # f.write(txt) # f.write(txthtml[1]) # f.close() if(browser==True):globals()['browser'](path.abspath(file))
def autohtml(file=None): import T if type(file) is not str: if file is None:file=stime()+'.html' else: if hasattr(file,'__name__'): if '.htm' not in file.__name__: file=file.__name__+'.html' else:file='obj_{0}.html'.format(hash(file)) elif len(T.filename(file))<1:file=stime()+'.html' elif '.htm' not in file.lower():file=file+'.html' return file
def printAttr(a,console=False): '''aoto call __methods which is no args''' d=py.dir(a) if console: sk='%-{0}s'.format(maxLen(d)) si='%-{0}s'.format(len(py.len( d ))) for i,k in py.enumerate(d): print si%i,sk%k,py.eval('a.{0}'.format(k)) return sh='''<tr> <td>{0}</td> <td id="n">{1}</td> <td><textarea>{2}</textarea></td> <td>{3}</td> </tr>''' sp=getModPath()+'file/attr.html' r='';v='';vi=-1 for i,k in py.enumerate(d): try: v=py.eval('a.{0}'.format(k)) vi=len(v) if py.callable(v) and k.startswith('__'): vv='!ErrGetV()' try:vv=v() except:pass v='{0} == {1}'.format(v,vv) if type(v) is not str: import pprint v= pprint.pformat(v) except Exception as e:v=py.repr(e) r+=sh.format(i,k,v,vi) # cdt('QPSU') import T name=gst+'QPSU/'+T.filename(getObjName(a))+'.html' write(name,read(sp).replace('{result}',r)) browser(name)