def add_item(self, meta, shareid, sharepath, fsize, directory): key = (shareid, sharepath) riter = self.folders.get(key) if riter != None: return riter if sharepath != '/' and meta.get('type') == SHARE_DIR: parent_path = dirname(sharepath) parent = self.add_item(meta, shareid, parent_path, '', True) else: parent = None guiname = basename(sharepath) if directory: filetype = 'folder' if guiname == '' and meta.get('description'): guiname = meta.get('description') guiname += '/' else: filetype = get_filetype(sharepath) guiname = cut_text(guiname, MAX_GUI_NAME) ft_icon = get_filetype_icon(filetype) riter = self.sharelist.append(parent, [meta, sharepath, directory, ft_icon, guiname, fsize]) if directory: self.folders[key] = riter return riter
def add_transfer(self, title, size, abort_cb, ctx=None, silent=False): self.open_filetransfergui() title = cut_text(title, MAX_TITLE) # popping up the transfer notification window, that returns # a handel to a function advancing its progressbar dialog = None if not silent: dialog = Transfer_Dialog(self.main_gui.get_main_window(), title, abort_cb, ctx) transfer = Transfer_Item(self, title, size, abort_cb, ctx, dialog) riter = self.transfer_list.append([self.ft_icon, title, 0, transfer, self.abort_icon]) transfer.iter = riter return transfer
def add_item(self, meta, user, shareid, sharepath, fsize, directory): key = (user, shareid, sharepath) riter = self.folders.get(key) if riter != None: return riter if sharepath != '/' and meta.get('type') == SHARE_DIR: parent_path = dirname(sharepath) parent = self.add_item(meta, user, shareid, parent_path, '', True) else: parent = None guiname = basename(sharepath) if directory: filetype = 'folder' if guiname == '' and meta.get('description'): guiname = meta.get('description') guiname += '/' else: filetype = get_filetype(sharepath) guiname = cut_text(guiname, MAX_GUI_NAME) ft_icon = get_filetype_icon(filetype) nick = user.get('nick') hops = user.get('hops') if hops == None: hops = 0 if hops < 4: color = self.HOP_COLORS[hops] else: color = self.HOP_COLORS[3] riter = self.content_list.append(parent, [meta, sharepath, user, directory, ft_icon, guiname, nick, fsize, color, hops]) if directory: self.folders[key] = riter return riter
def main(): (infile, regexp) = Helper.parse_args() utils.cut_text(infile, regexp)
"datetime": parser.parse(dt), "text": text.rstrip().rstrip("("), "meta": { "arabic": arabic } }) text = "" arabic = False # nickname, uid, time_ = meta dt, nickname, uid = meta else: for char in line: if is_arabic(char): arabic = True break text += line return result chat_history = [] chat_history.extend(loader("base.txt")) chat_history.extend(legacy_loader("20200303.txt", datetime(2020, 3, 3, 0, 0, 0))) chat_history.extend(legacy_loader("20200304.txt", datetime(2020, 3, 4, 0, 0, 0))) chat_history.extend(loader("20200305_new.txt")) with open("output.pickle", mode="wb") as f: pickle.dump(chat_history, f) text_lib = TextLib(cut_text(list(filter(lambda x: not x["meta"]["arabic"], chat_history)))) with open("text_lib.vocab", mode="wb") as f: pickle.dump(text_lib, f)