__author__ = 'jens' import util # Remove all double entries and entries that have an extension out of the second list print 'Base set' base = util.create_set(util.raw_multi_line_input(), lambda s: s.lower()) print 'Extensions to remove from base' to_del = util.create_set(util.raw_multi_line_input(), lambda s: s.lower()) for to_del_entry in to_del: base_set = set(base) for entry in base_set: if entry.lower().endswith(to_del_entry.lower()): base.remove(entry) util.copy_to_clipboard(sorted(base, key=str.lower))
import re import os import util # Gets all lines in xls or csv files by given regex and folder folderName = raw_input('Folder: ') filePattern = raw_input('Regex: ') is_csv = filePattern.endswith('.csv') mails = [] read = 1 for file in os.listdir(folderName): if re.match(filePattern, file): if is_csv: with open(folderName + "/" + file) as csvfile: for row in csvfile: mails.extend(re.findall(r'[\w\.-]+@[\w\.-]+', row)) else: book = xlrd.open_workbook(folderName + "/" + file) for sheet in book.sheets(): for row in sheet.get_rows(): for cell in row: if type(cell.value) is unicode: mails.extend(re.findall(r'[\w\.-]+@[\w\.-]+', cell.value)) print('Files read: ' + repr(read)) read += 1 print('Filtering double mails (total mails ' + repr(len(mails)) + ')') util.copy_to_clipboard(sorted(util.create_set(mails, lambda s: s.lower()), key=(str.lower if is_csv else unicode.lower)))
__author__ = 'jens' import util # Remove all double entries and entries that don't have a given extension out of the second list print 'Base set' base = util.create_set(util.raw_multi_line_input(), lambda s: s.lower()) print 'Extensions to find in base' to_find = util.create_set(util.raw_multi_line_input(), lambda s: s.lower()) found = [] for to_find_entry in to_find: for entry in base: if entry.lower().endswith(to_find_entry.lower()): found.append(entry) util.copy_to_clipboard(sorted(found, key=str.lower))
__author__ = 'jens' import re import os import util # Gets all lines in files by given regex and folder folderName = raw_input('Folder: ') filePattern = raw_input('Regex: ') lines = [] for file in os.listdir(folderName): if re.match(filePattern, file): lines.extend(open(folderName + "/" + file).read().split('\n')) util.copy_to_clipboard(lines)
__author__ = 'jens' import util # Read multi line input and count times each line occers # This will also trim all leading and trailing spaces multiLineInput = util.raw_multi_line_input() counter = dict() for line in multiLineInput: if line in counter: counter[line] += 1 else: counter[line] = 1 util.copy_to_clipboard(counter)
def input_handler(self, input): if not isinstance(input, (str, unicode)): return input if input in self.shortcuts["exit"]: if self.path_filter.is_popup_opened(): self.path_filter.close_popup() else: raise urwid.ExitMainLoop() if input in self.shortcuts["cd_selected_path"]: if self.path_filter.is_popup_opened(): selected = self.path_filter.popup.get_selected() dirname = os.path.dirname(self.path_filter.get_text()) path = os.path.join(dirname, selected.get_path()) + "/" self.path_filter.set_text(path) self.path_filter.close_popup() else: selected = self.listbox.get_focus()[0] if selected: path = selected.get_path() else: path = self.path_filter.get_text() self.change_directory(path) return if input in self.shortcuts["cd_entered_path"]: self.change_directory(self.path_filter.get_text()) return if input in self.shortcuts["copy_selected_path_to_clipboard"]: selected = self.listbox.get_focus()[0] if selected: util.copy_to_clipboard(selected.get_path()) if self.config["exit_after_coping_path"]: raise urwid.ExitMainLoop() return if input in self.shortcuts["autocomplete"]: path = self.path_filter.get_text() if not path.startswith("~") and not path.startswith("/"): path = self.extend_path_filter_text() or path # TODO ??? hack if path == "~": path = path_strip(path) self.path_filter.set_text(path) self.path_filter.autocomplete() # rename shortcut name if input in self.shortcuts["paste_selected_path"]: self.extend_path_filter_text() if input in self.shortcuts["remove_word"]: path = self.path_filter.get_text() path = path_strip(path) if "/" in path: path, _ = path.rsplit("/", 1) if path: path += "/" self.path_filter.set_text(path) else: self.path_filter.set_text("") if input in self.shortcuts["case_sensitive"]: self.case_sensitive = not self.case_sensitive if input in self.shortcuts["fuzzy_search"]: self.fuzzy_search = not self.fuzzy_search self.search_engine_label.set_text(self.get_search_engine_label_text()) if input in self.shortcuts["search_pos"]: self.search_from_any_pos = not self.search_from_any_pos self.search_engine_label.set_text(self.get_search_engine_label_text()) if input in self.shortcuts["inc_search_offset"]: self.search_offset += 1 if input in self.shortcuts["dec_search_offset"]: self.search_offset -= 1 if self.search_offset < 0: self.search_offset = 0 if input in self.shortcuts["cd_to_shortcut_path"]: path = get_shortcut_path(self.shortcuts_paths_filename, self.shortcuts["cd_to_shortcut_path"].index(input)) if path: if self.config["exit_after_pressing_path_shortcut"]: self.selected_path = path raise urwid.ExitMainLoop() else: path = util.replace_home_with_tilde(path) if self.config["append_asterisk_after_pressing_path_shortcut"]: path += "*" self.path_filter.set_text(path) else: # do nothing return if input in self.shortcuts["store_shortcut_path"]: selected = self.listbox.get_focus()[0] if selected: selected_path = expanduser(selected.get_path()) store_shortcut_path(self.shortcuts_paths_filename, selected_path, self.shortcuts["store_shortcut_path"].index(input)) return # clean up header self.info_text_header.set_text("") if input in self.shortcuts["clean_input"]: self.path_filter.set_text("") # display input if it is not a shortcut if not self.is_shortcut(input): self.path_filter.keypress((20,), input) # Remove offset if there is no output if not self.path_filter.get_text(): self.search_offset = 0 # update popup content if self.path_filter.is_popup_opened(): path = self.path_filter.get_text() path, dirs, prefix = self.path_filter.parse_path(path) if dirs: self.path_filter.popup.update(dirs, prefix) else: self.path_filter.close_popup() # don't re-render listbox extra time if input not in ["up", "down", "left", "right"]: self.update_listbox()
import util # Gets all lines in xls or csv files by given regex and folder folderName = raw_input('Folder: ') filePattern = raw_input('Regex: ') is_csv = filePattern.endswith('.csv') mails = [] read = 1 for file in os.listdir(folderName): if re.match(filePattern, file): if is_csv: with open(folderName + "/" + file) as csvfile: for row in csvfile: mails.extend(re.findall(r'[\w\.-]+@[\w\.-]+', row)) else: book = xlrd.open_workbook(folderName + "/" + file) for sheet in book.sheets(): for row in sheet.get_rows(): for cell in row: if type(cell.value) is unicode: mails.extend( re.findall(r'[\w\.-]+@[\w\.-]+', cell.value)) print('Files read: ' + repr(read)) read += 1 print('Filtering double mails (total mails ' + repr(len(mails)) + ')') util.copy_to_clipboard( sorted(util.create_set(mails, lambda s: s.lower()), key=(str.lower if is_csv else unicode.lower)))
__author__ = 'jens' import util # Find all entries in that are in both sets print 'Set one' base = util.create_set(util.raw_multi_line_input(), lambda s: s.lower()) print 'Set two' to_match = util.create_set(util.raw_multi_line_input(), lambda s: s.lower()) util.copy_to_clipboard(sorted(base.intersection(to_match), key=str.lower))
__author__ = 'jens' import util import re # Extract email extensions from a list of mails use mailExtract.py first to get mails from text text = util.raw_multi_line_input() util.copy_to_clipboard(re.findall(r'@[\w\.-]+', ' '.join(text)))
__author__ = 'jens' import util import re # Extracts belgian phone numbers from text lines = util.raw_multi_line_input() pattern = "(?:\+32|0032|0)(\d{8}\d?)" phones = [] for line in lines: phones.extend(re.findall(pattern, line.translate(None, '/. '))) phones = ["0032" + phone for phone in phones] util.copy_to_clipboard(phones)
__author__ = 'jens' import util # Read multi line input and copies all unique lines to the clipboard # This will also trim all leading and trailing spaces multiLineInput = util.raw_multi_line_input() uniqueSorted = util.trim(sorted(util.create_set(multiLineInput, lambda s: s.lower()), key=str.lower)) util.copy_to_clipboard(uniqueSorted)
__author__ = 'jens' import util # Remove all double entries and entries that are also in the second set print 'Base set' base = util.create_set(util.raw_multi_line_input(), lambda s: s.lower()) print 'To remove from base' to_del = util.create_set(util.raw_multi_line_input(), lambda s: s.lower()) util.copy_to_clipboard(sorted(base.difference(to_del), key=str.lower))
__author__ = 'jens' import util # Read multi line input and copies all unique lines to the clipboard # This will also trim all leading and trailing spaces multiLineInput = util.raw_multi_line_input() uniqueSorted = util.trim( sorted(util.create_set(multiLineInput, lambda s: s.lower()), key=str.lower)) util.copy_to_clipboard(uniqueSorted)