Guest User

Untitled

a guest
Dec 23rd, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. from imap_tools import MailBox, AND, OR, NOT
  4. from pprint import pprint
  5.  
  6. def createIfNotExistAndMoveToFolder(mailboxStream, searchTerm, msguid, MoveToFolder):
  7.     # Filter a list of string using lamda expression = https://linuxhint.com/filter_list_strings_python/
  8.     # Declare a list that contains the search word
  9.     search_word = ["INBOX"]
  10.     # Define the folder_original where the word from the list will search
  11.     folder_original = MoveToFolder.strip()
  12.     # Split the folder_original based on space and store the words in a list
  13.     folder_split = folder_original.split('.')
  14.     pprint(folder_split)
  15.     # Using lambda expression filter the data
  16.     filter_list = list(filter(lambda val: val not in search_word, folder_split))
  17.     pprint(filter_list)
  18.  
  19.     folderPath = "INBOX"
  20.     for item in filter_list:
  21.         folderPath += "." + item
  22.         print(folderPath)
  23.  
  24. mailboxStream = "fake"
  25. createIfNotExistAndMoveToFolder(mailboxStream, 'search word / term', '1', 'INBOX.mainfolder.subfolder.subofsubfolder')
Advertisement
Add Comment
Please, Sign In to add comment