Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 11th, 2012  |  syntax: Python  |  size: 1.30 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env python
  2. from sievelib.parser import Parser
  3. from sievelib.factory import FiltersSet
  4.  
  5. filter = u"""
  6. require "fileinto";
  7. require "envelope";
  8. require "cp_extension";
  9.  
  10. if address :contains ["From", "Sender"]
  11.  ["alsdjaskldjioqwdpqjpdj@asjkdn.com",
  12.  "bla.com",
  13.  "blabla.co.uk",
  14.  "test@bla.com"]
  15.  { discard; stop; }
  16.  
  17.  
  18. # cp_filter_name: Filter1
  19. if allof (
  20.  not address :is ["From", "Sender"] ["from"] ,
  21.  address :contains ["To"] ["toasd"] ,
  22.  header :contains ["Subject"] ["subjecthere"] ,
  23.  not header :contains "X-Priority" ["1", "2", "4", "5"] ,
  24.  size :over 113664 ,
  25.  envelope :contains ["To"] ["13223"])
  26.  {
  27.  fileinto "INBOX";
  28.  redirect "forward@t.de";
  29.  discard;
  30.  stop;
  31.  }
  32.  
  33.  
  34. # cp_filter_name: Filter2
  35. # cp_filter_description: Descri2
  36. if allof (
  37.  not address :is ["From", "Sender"] ["from"] ,
  38.  address :contains ["To"] ["toasd"] ,
  39.  header :contains ["Subject"] ["subjecthere"] ,
  40.  not header :contains "X-Priority" ["1", "2", "4", "5"] ,
  41.  size :over 113664 ,
  42.  envelope :contains ["To"] ["13223"])
  43.  {
  44.  fileinto "INBOX";
  45.  redirect "forward@t.de";
  46.  discard;
  47.  stop;
  48.  }
  49.  
  50.  
  51. """
  52.  
  53. p = Parser()
  54.  
  55. if p.parse(filter) == False:
  56.     print "ERROR: " + str(p.error)
  57.     exit(1)
  58. p.dump()
  59.  
  60. f = FiltersSet("new filterset")
  61. f.from_parser_result(p)
  62. f.tosieve()
clone this paste RAW Paste Data