Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- from imap_tools import MailBox, AND, OR, NOT
- from pprint import pprint
- def createIfNotExistAndMoveToFolder(mailboxStream, searchTerm, msguid, MoveToFolder):
- # Filter a list of string using lamda expression = https://linuxhint.com/filter_list_strings_python/
- # Declare a list that contains the search word
- search_word = ["INBOX"]
- # Define the folder_original where the word from the list will search
- folder_original = MoveToFolder.strip()
- # Split the folder_original based on space and store the words in a list
- folder_split = folder_original.split('.')
- pprint(folder_split)
- # Using lambda expression filter the data
- filter_list = list(filter(lambda val: val not in search_word, folder_split))
- pprint(filter_list)
- folderPath = "INBOX"
- for item in filter_list:
- folderPath += "." + item
- print(folderPath)
- mailboxStream = "fake"
- createIfNotExistAndMoveToFolder(mailboxStream, 'search word / term', '1', 'INBOX.mainfolder.subfolder.subofsubfolder')
Advertisement
Add Comment
Please, Sign In to add comment