def html_tick(fname): global conf, mw conf.recurse = False try: fh = open(fname) ht = pubhtml.HTML_Parser(conf) ht.mw = mw ht.fh = fh ht.getimagecb = getimagecb ln = 0 mw.waitcursor(True) while 1: if conf.recurse: break sss = fh.readline() if ln % 10 == 0: mw.prog.set_text("Reading line: %d" % ln) usleep(1) ln += 1 if sss == "": break if conf.recurse: break if ht.feed(sss): break mw.add_text(sss, True) mw.fname = fname mw.waitcursor(False) except: print_exception("Opening HTML") mw.prog.set_text("Done Loading.") mw.hpaned.set_position(0) mw.gohome()
def openHTML(zf, fname, mark = True): # Is it a tagged link? ppp = fname.find("#") spl = [] if spl >= 0: spl = fname.split("#") fname = spl[0] # Not loaded, load if mw.fname != fname: mw.clear(); mw.clear(True); found = False; fh = None try: fh = zf.open(fname) found = True except: #print "searching for", fname, sys.exc_info() # Search for it ... for aa in zf.infolist(): #print aa.filename, fname if os.path.basename(aa.filename) == fname: try: fh = zf.open(aa.filename) except: print_exception("No Zip File") return found = True break if not found: return False try: #ht = MyHTMLParser(mw) ht = pubhtml.HTML_Parser() ht.mw = mw; ht.mark = mark; ht.fh = fh mw.waitcursor(True) while 1: sss = fh.readline() if sss == "": break if ht.feed(sss): break mw.add_text(sss, True) mw.fname = fname mw.waitcursor(False) except: print_exception("Parsing HTML") # Jump to tag, if any if len(spl) > 1: #print "Jumping to", "'" + spl[1] + "'" mm = mw.buffer_1.get_mark(spl[1]) if mm: mw.view.scroll_to_mark(mm, 0.0, True, 0, 0) return True
def openHTML(zf, fname, mark=True): global conf found = False fh = None spl = [] ht = None conf.recurse = False # Is it a link with a tag? spl = fname.split("#") # Not loaded, load if mw.fname != spl[0]: mw.clearall() found = False fh = None usleep(1) try: fh = zf.open(spl[0]) found = True except: for aa in zf.infolist(): if os.path.basename(aa.filename) == os.path.basename(spl[0]): #print "found", aa.filename try: fh = zf.open(aa.filename) except: print_exception("No Zip File") return found = True break if not found: return False try: ht = pubhtml.HTML_Parser(conf) ht.mw = mw ht.mark = mark ht.fh = fh ht.getimagecb = getimagecb ln = 0 mw.waitcursor(True) while 1: if conf.recurse: break if mw.stopload: break sss = fh.readline() if mw.stopload: break if ln % 10 == 0: mw.prog.set_text("Reading line: %d" % ln) usleep(1) ln += 1 if sss == "": break if conf.recurse: break if ht.feed(sss): break mw.add_text(sss, True) mw.fname = spl[0] mw.waitcursor(False) except: print_exception("Parsing HTML") #if mw.stopload: # return mw.prog.set_text("Done Loading.") usleep(10) if mw.stopload: return # Jump to tag, if any if len(spl) > 1: #print "Jumping to", "'" + spl[1] + "'" mm = mw.buffer_1.get_mark(spl[1]) if mm: ii = mw.buffer_1.get_iter_at_mark(mm) mw.buffer_1.place_cursor(ii) mw.view.scroll_to_mark(mm, 0.0, True, 0, 0) else: mw.gohome() return True
def openHTML(zf, fname, mark=True): global conf # Is it a tagged link? ppp = fname.find("#") spl = [] if spl >= 0: spl = fname.split("#") fname = spl[0] # Not loaded, load if mw.fname != fname: #print "loading", fname mw.clear() mw.clear(True) found = False fh = None try: fh = zf.open(fname) found = True except: #print "searching for", fname, sys.exc_info() # Search for it ... for aa in zf.infolist(): #print aa.filename, fname if os.path.basename(aa.filename) == fname: try: fh = zf.open(aa.filename) except: print_exception("No Zip File") return found = True break if not found: return False try: ht = pubhtml.HTML_Parser(conf) ht.mw = mw ht.mark = mark ht.fh = fh ht.getimagecb = getimagecb ln = 0 mw.waitcursor(True) while 1: sss = fh.readline() if ln % 10 == 0: mw.prog.set_text("Reading line: %d" % ln) usleep(1) ln += 1 if sss == "": break if ht.feed(sss): break mw.add_text(sss, True) mw.fname = fname mw.waitcursor(False) except: print_exception("Parsing HTML") mw.prog.set_text("Done Reading.") usleep(10) # Jump to tag, if any if len(spl) > 1: #print "Jumping to", "'" + spl[1] + "'" mm = mw.buffer_1.get_mark(spl[1]) ii = mw.buffer_1.get_iter_at_mark(mm) if mm: mw.view.scroll_to_mark(mm, 0.0, True, 0, 0) else: mw.gohome() return True