def headers_for_line_evts(self, row, row2): """Line Event""" idx, pth, lno, evt, dta, ogi = row idx2, pth2, lno2, evt2, dta2, ogi2 = row2 if "line" not in evt and "line" in evt2: le1, le2, le3 = fmt_syms.get_LE() header = MutableStr(f"{le1} {ogi}-") self.line_header_stack.append(header) self.line_header_switch = True return [row, header] elif "line" in evt and "line" not in evt2: if self.line_header_stack: header = self.line_header_stack.pop() m = re.search(r"\d+[-]$", str(header)) og1 = m.group()[:-1] og2 = ogi2 - 1 diff = int(og2) - int(og1) header.modify_inplace(f"{og2}({diff})") return [ ] # returning row causes header_row += row to convert pd.core.frame to list else: return [] else: assert "line" in evt and "line" in evt2, f"{evt=}, {evt2=}" return []
def headers_for_line_evts(self,row,row2): """Line Event""" idx,pth,lno,evt,mos,pos,raw,ogi = row idx2,pth2,lno2,evt2,mos2,pos2,raw2,ogi2 = row2 pth,pth2 = Path(pth).stem,Path(pth2).stem t3=fmt_syms.get_tier3() if "line" not in evt and "line" in evt2: header = MutableStr(f"{t3} {ogi}-") self.line_header_stack.append(header) self.line_header_switch = True return HeaderRow(header=header,row=row) elif "line" in evt and "line" not in evt2: if self.line_header_stack: header = self.line_header_stack.pop() m = re.search(r"\d+[-]$",str(header)) og1 = m.group()[:-1] og2 = ogi2 - 1 diff = int(og2) - int(og1) header.modify_inplace(f"{diff}") return [] # returning row causes header_row += row to convert pd.core.frame to list else: return [] else: assert "line" in evt and "line" in evt2, f"{evt=}, {evt2=}" return []
def headers_for_ydl(self, row, row2): idx,pth,lno,evt,mos,pos,raw,ogi = row idx2,pth2,lno2,evt2,mos2,pos2,raw2,ogi2 = row2 pth,pth2 = Path(pth).stem,Path(pth2).stem t2=fmt_syms.get_tier2() if self.ydl_header_switch: self.ydl_header_switch = False header = MutableStr(f"{t2} {ogi+1}-") self.ydl_header_stack.append(header) return HeaderRow(row=row,header=header) elif "YoutubeDL" not in pth and "YoutubeDL" in pth2: # interp. see headers_for_init self.ydl_header_switch = True # return [] # returning row causes header_row += row to convert pd.core.frame to list elif "YoutubeDL" in pth and "YoutubeDL" not in pth2: # interp. see headers_for_init if self.ydl_header_stack: header = self.ydl_header_stack.pop() header.modify_inplace(f"{ogi2}") else: with open('f173','w') as f: f.write(row) f.write(row2) raise SystemExit else: assert "YoutubeDL" in pth and "YoutubeDL" in pth2, f"{pth=}, {pth2=}"
def headers_for_init(self, row, row2): idx,pth,lno,evt,mos,pos,raw,ogi = row idx2,pth2,lno2,evt2,mos2,pos2,raw2,ogi2 = row2 pth,pth2 = Path(pth).stem,Path(pth2).stem t1=fmt_syms.get_tier1() if self.init_header_switch: self.init_header_switch = False header = MutableStr(f"{t1} {ogi+1}-") self.init_header_stack.append(header) return HeaderRow(row=row,header=header) elif "__init__" not in pth and "__init__" in pth2: # interp. pth2 will be a "first" of (possibly) adjacent init's. # therefore, pth2 will need a header, which will preceed it. # bc its pth2 that needs the header (not pth) # flip the switch for the next iteration (when pth2 => pth) self.init_header_switch = True # return [] # returning row causes header_row += row to convert pd.core.frame to list elif "__init__" in pth and "__init__" not in pth2: # interp. we are leaving the adjacent sequence of init's # update the header with the og_index, and pop from the stack if self.init_header_stack: header = self.init_header_stack.pop() header.modify_inplace(f"{ogi2}") else: with open('f148','w') as f: f.write(row) f.write(row2) raise SystemExit else: assert "__init__" in pth and "__init__" in pth2, f"{pth=}, {pth2=}"
def headers_for_init(self, row, row2): idx,pth,lno,evt,mos,pos,ogi = row idx2,pth2,lno2,evt2,mos2,pos2,ogi2 = row2 t1,t2,t3 = fmt_syms.get_Tier1() if "__init__" in pth and "__init__" not in pth2: header = MutableStr(f"{t1} #region1 {ogi+1}") self.init_header_stack.append(header) self.init_header_switch = True return [] # returning row causes header_row += row to convert pd.core.frame to list elif "__init__" not in pth and "__init__" in pth2: if self.init_header_stack: self.init_endheader_switch = True header = self.init_header_stack.pop() header.modify_inplace(f"-{ogi2}") m = re.search(r"\d+[-]\d+", str(header)) og_nums = m.group() endheader = MutableStr(f"{t1} #endregion1 {og_nums}") return HeaderRow(row=row,header=endheader) else: return [] else: assert "__init__" in pth and "__init__" in pth2, f"{pth=}, {pth2=}" return []
def headers_for_ydl(self, row): indent = " " idx, pth, lno, evt, dta, ogi = row rgx = re.compile(r"(?P<funcname>[\<A-z][A-z0-9_\>]*)(?P<rest>.*)") t1, t2, t3 = fmt_syms.get_Tier2() if evt == "call": sym, cod = dta.split(" ", 1) assert sym == "=>", sym m = rgx.match(cod) gd = m.groupdict() header = MutableStr(f"{t1}#region2 {ogi}-") self.ydl_header_stack.append(header) return [row, header] elif evt == "return": sym, cod = dta.split(" ", 1) assert sym == "<=", sym m = rgx.match(cod) gd = m.groupdict() header = self.ydl_header_stack.pop() header.modify_inplace(f"{ogi}") endheader = MutableStr(f"{t1}#endregion2") return [endheader, row] else: return []