#!/usr/bin/python
from distutils.core import setup
setup(
  name = 'cs.app.mailfiler',
  description = 'email message filing system which monitors multiple inbound Maildir folders',
  author = 'Cameron Simpson',
  author_email = 'cs@zip.com.au',
  version = '20160402',
  url = 'https://bitbucket.org/cameron_simpson/css/commits/all',
  classifiers = ['Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Topic :: Software Development :: Libraries :: Python Modules', 'Operating System :: OS Independent', 'Development Status :: 4 - Beta', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 'Intended Audience :: Developers'],
  entry_points = {'console_scripts': ['mailfiler = cs.app.mailfiler:main']},
  keywords = ['python2', 'python3'],
  long_description = u'Mailfiler: another mail filing system.\n======================================\n\nMailfiler is my personal mail filing tool. It will monitor multiple spool mail folders and file messages which appear in them according to per-folder rules and are succinct, readable, robust and flexible.\n\nRule Syntax\n-----------\n\nThe rule syntax is detailed in mailfiler_5_pod_, but in short::\n\n  target,... label  condition\n                    condition\n                    ...\n\nA target can be:\n\na mail folder name, such as "python",\n\nan email address, such as the special mail address my phone consults, or that of another person who should always receive copies of specific messages,\n\na shell command, such as a command to log receipt of a message or to automatically process its contents; many message header details are presented in as shell environment variables for ready use without further header parsing. For example, I pass certain work related messages to this command::\n\n  buglog -n -B dlog "WORK: $shortlist_from->$shortlist_to_cc_bcc: $header_subject"\n\na header modification instruction, of the form "header:s/this/that/", one use for such is described here: fix-dkim-from_\n\nThe "label", if not ".", is added to the X-Label: header.\n\nThe conditions take several forms:\n\na bare core email address such as bill@example.com:\n  matches a message with this core address in the to/cc/bcc header\n\na header:address pair such as "from:joe@example.com" or "to,cc:bill@example.com"\n  these match "joe@example.com" in the From: header or "bill@example.com" in the to/cc headers\n\na header:/regexp such as "subject:/^FAIL:"\n  matches a Subject: header starting with "FAIL:"\n\nsome specialty match syntaxes\n\nMultiple conditions may be supplied; all must match.\n\nNotably, the core address syntax also accepts: "@example.com" to match any address from the "example.com" domain, "UPPERCASE_NAME" to match any address in the group "lowercase_name" in the maildb (see cs.app.maildb_). These can be combined, such as "(@work.example.com|COLLEAGUES|joe-the-consultant@example.com)".\n\nMy Setup\n--------\n\nLike others, I run my personal email fairly decoupled: I use one tool (getmail, currently) to collect email and deliver to a spool folder, another tool (this one, mailfiler) to monitor that spool and file to other mail folders, a third tool to read and compose email (mutt) and my local machine\'s mail system to actually queue and send the email.\n\nI start an instance of mailfiler at login, in a tmux session, and an instance of getmail likewise. My email is then collected and filed.\n\nWhy not procmail?\n-----------------\n\nI used to use procmail; it is popular and does its job.\nHowever, its rule syntax is verbose and sometimes arcane.\nEven the simplest rule tends to require multiple lines, and I have hundreds of rules.\nThis drove me to write my now defunct cats2procmailrc tool which took rules much like the mailfiler rules and generated a procmailrc.\n\nHowever, procmail has other problems as well:\n\nIt is sloppy:\n  All the matching rules are in fact regular expressions.\n  While regular expressions are flexible, they are also error prone and hard to write well and robustly.\n  And for email addresses, regexps are awful:\n  a) the dots in email address are wildcards in regexps, and must be escaped for robustness\n  b) email addresses come in multiple forms, notably "Bill <bill@example.com>" and the uglier "(Bill) bill@example.com": to reliably match these you need two expressions with different address boundary conditions; the former is usually tested with "<bill@example.com>", the latter is not so easily done in a reliable manner.\n  By constrast, mailfiler does a proper RFC2822 parse of the address and matches against the "core address", "bill@example.com" in the example, with a direct string comparison.\n  So there is no risk of matching "wildbill@example.com" or "bill@example.com.au", and no requirements on a particular form of the address on arrival.\n\nIt is slow:\n  Procmail is invoked separately for each message to file, and it must read its rules and compile all its regular expressions every time.\n  The expressions are applied as encountered, effectively reparsing each message header every time it is tested for a match.\n  By contrast, mailfiler parses its rules once at startup (and again whenever the rules file is modified); also, during message matching mailfiler parses address headers only once, as requested, and keeps the post-parse data (core address) around for direct access in any future match.\n  The match tests are also largely direct string comparisons, much cheaper than a regexp even discounting the regexp compile cost.\n\nIt is hard to use for ad hoc message filing:\n  If you can get your message into a separate file, you can test on the command line with "procmail < message". This is not always convenient, especially from inside a mail reader.\n  By contrast, to test a mailfiler ruleset I can just update the ruleset, copy a sample message into the spool folder using my mail reader\'s normal message copy function, and watch the logfile to see the actions taken.\n  Once correct, it is similarly easy to bulk refile many messages by dumping them into the spool directory.\n\n.. _mailfiler_5_pod: https://bitbucket.org/cameron_simpson/css/src/tip/man/mailfiler.5.pod\n.. _cs.app.maildb: https://pypi.python.org/pypi/cs.app.maildb\n.. _fix-dkim-from: http://marc.info/?l=mutt-users&m=142006430708261&w=2\n',
  package_dir = {'': 'lib/python'},
  py_modules = ['cs.app.mailfiler'],
  requires = ['cs.configutils', 'cs.env', 'cs.fileutils', 'cs.lex', 'cs.logutils', 'cs.mailutils', 'cs.obj', 'cs.seq', 'cs.threads', 'cs.app.maildb', 'cs.py.modules', 'cs.py3'],
)
