⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 options.py

📁 用python实现的邮件过滤器
💻 PY
📖 第 1 页 / 共 5 页
字号:
     _("""If you activated the HTTP authentication option, you can modify the     authorized user password here."""),     r"[\w]+", RESTORE),    ("rows_per_section", _("Rows per section"), 10000,     _("""Number of rows to display per ham/spam/unsure section."""),     INTEGER, RESTORE),  ),  "imap" : (    ("server", _("Server"), (),     _("""These are the names and ports of the imap servers that store your     mail, and which the imap filter will connect to - for example:     mail.example.com or imap.example.com:143.  The default IMAP port is     143 (or 993 if using SSL); if you connect via one of those ports, you     can leave this blank. If you use more than one server, use a comma     delimited list of the server:port values."""),     SERVER, DO_NOT_RESTORE),    ("username", _("Username"), (),     _("""This is the id that you use to log into your imap server.  If your     address is funkyguy@example.com, then your username is probably     funkyguy."""),     IMAP_ASTRING, DO_NOT_RESTORE),    ("password", _("Password"), (),     _("""That is that password that you use to log into your imap server.     This will be stored in plain text in your configuration file, and if     you have set the web user interface to allow remote connections, then     it will be available for the whole world to see in plain text.  If     I've just freaked you out, don't panic <wink>.  You can leave this     blank and use the -p command line option to imapfilter.py and you will     be prompted for your password."""),     IMAP_ASTRING, DO_NOT_RESTORE),    ("expunge", _("Purge//Expunge"), False,     _("""Permanently remove *all* messages flagged with //Deleted on logout.     If you do not know what this means, then please leave this as     False."""),     BOOLEAN, RESTORE),    ("use_ssl", _("Connect via a secure socket layer"), False,     _("""Use SSL to connect to the server. This allows spambayes to connect     without sending the password in plain text.     Note that this does not check the server certificate at this point in     time."""),     BOOLEAN, DO_NOT_RESTORE),    ("filter_folders", _("Folders to filter"), ("INBOX",),     _("""Comma delimited list of folders to be filtered"""),     IMAP_FOLDER, DO_NOT_RESTORE),    ("unsure_folder", _("Folder for unsure messages"), "",     _(""""""),     IMAP_FOLDER, DO_NOT_RESTORE),    ("spam_folder", _("Folder for suspected spam"), "",     _(""""""),     IMAP_FOLDER, DO_NOT_RESTORE),    ("ham_folder", _("Folder for ham messages"), "",     _("""If you leave this option blank, messages classified as ham will not     be moved.  However, if you wish to have ham messages moved, you can     select a folder here."""),     IMAP_FOLDER, DO_NOT_RESTORE),        ("ham_train_folders", _("Folders with mail to be trained as ham"), (),     _("""Comma delimited list of folders that will be examined for messages     to train as ham."""),     IMAP_FOLDER, DO_NOT_RESTORE),    ("spam_train_folders", _("Folders with mail to be trained as spam"), (),     _("""Comma delimited list of folders that will be examined for messages     to train as spam."""),     IMAP_FOLDER, DO_NOT_RESTORE),    ("move_trained_spam_to_folder", _("Folder to move trained spam to"), "",     _("""When training, all messages in the spam training folder(s) (above)     are examined - if they are new, they are used to train, if not, they     are ignored.  This examination does take time, however, so if speed     is an issue for you, you may wish to move messages out of this folder     once they have been trained (either to delete them or to a storage     folder).  If a folder name is specified here, this will happen     automatically.  Note that the filter is not yet clever enough to     move the mail to different folders depending on which folder it     was originally in - *all* messages will be moved to the same     folder."""),     IMAP_FOLDER, DO_NOT_RESTORE),    ("move_trained_ham_to_folder", _("Folder to move trained ham to"), "",     _("""When training, all messages in the ham training folder(s) (above)     are examined - if they are new, they are used to train, if not, they     are ignored.  This examination does take time, however, so if speed     is an issue for you, you may wish to move messages out of this folder     once they have been trained (either to delete them or to a storage     folder).  If a folder name is specified here, this will happen     automatically.  Note that the filter is not yet clever enough to     move the mail to different folders depending on which folder it     was originally in - *all* messages will be moved to the same     folder."""),     IMAP_FOLDER, DO_NOT_RESTORE),  ),  "ZODB" : (    ("zeo_addr", _(""), "",     _(""""""),     IMAP_ASTRING, DO_NOT_RESTORE),    ("event_log_file", _(""), "",     _(""""""),     IMAP_ASTRING, RESTORE),    ("folder_dir", _(""), "",     _(""""""),     PATH, DO_NOT_RESTORE),    ("ham_folders", _(""), "",     _(""""""),     PATH, DO_NOT_RESTORE),    ("spam_folders", _(""), "",     _(""""""),     PATH, DO_NOT_RESTORE),    ("event_log_severity", _(""), 0,     _(""""""),     INTEGER, RESTORE),    ("cache_size", _(""), 2000,     _(""""""),     INTEGER, RESTORE),  ),  "imapserver" : (    ("username", _("Username"), "",     _("""The username to use when logging into the SpamBayes IMAP server."""),     IMAP_ASTRING, DO_NOT_RESTORE),    ("password", _("Password"), "",     _("""The password to use when logging into the SpamBayes IMAP server."""),     IMAP_ASTRING, DO_NOT_RESTORE),    ("port", _("IMAP Listen Port"), 143,     _("""The port to serve the SpamBayes IMAP server on."""),     PORT, RESTORE),  ),  "globals" : (    ("verbose", _("Verbose"), False,     _(""""""),     BOOLEAN, RESTORE),    ("dbm_type", _("Database storage type"), "best",     _("""What DBM storage type should we use?  Must be best, db3hash,     dbhash or gdbm.  Windows folk should steer clear of dbhash.  Default     is "best", which will pick the best DBM type available on your     platform."""),     ("best", "db3hash", "dbhash", "gdbm"), RESTORE),    ("proxy_username", _("HTTP Proxy Username"), "",     _("""The username to give to the HTTP proxy when required.  If a     username is not necessary, simply leave blank."""),     r"[\w]+", DO_NOT_RESTORE),    ("proxy_password", _("HTTP Proxy Password"), "",     _("""The password to give to the HTTP proxy when required.  This is     stored in clear text in your configuration file, so if that bothers     you then don't do this.  You'll need to use a proxy that doesn't need     authentication, or do without any SpamBayes HTTP activity."""),     r"[\w]+", DO_NOT_RESTORE),    ("proxy_server", _("HTTP Proxy Server"), "",     _("""If a spambayes application needs to use HTTP, it will try to do so     through this proxy server.  The port defaults to 8080, or can be     entered with the server:port form."""),     SERVER, DO_NOT_RESTORE),    ("language", _("User Interface Language"), ("en_US",),     _("""If possible, the user interface should use a language from this     list (in order of preference)."""),     r"\w\w(?:_\w\w)?", RESTORE),  ),}# `optionsPathname` is the pathname of the last ini file in the list.# This is where the web-based configuration page will write its changes.# If no ini files are found, it defaults to bayescustomize.ini in the# current working directory.optionsPathname = None# The global options object - created by load_optionsoptions = Nonedef load_options():    global optionsPathname, options    options = OptionsClass()    options.load_defaults(defaults)    # Maybe we are reloading.    if optionsPathname:        options.merge_file(optionsPathname)    alternate = None    if hasattr(os, 'getenv'):        alternate = os.getenv('BAYESCUSTOMIZE')    if alternate:        filenames = alternate.split(os.pathsep)        options.merge_files(filenames)        optionsPathname = os.path.abspath(filenames[-1])    else:        alts = []        for path in ['bayescustomize.ini', '~/.spambayesrc']:            epath = os.path.expanduser(path)            if os.path.exists(epath):                alts.append(epath)        if alts:            options.merge_files(alts)            optionsPathname = os.path.abspath(alts[-1])    if not optionsPathname:        optionsPathname = os.path.abspath('bayescustomize.ini')        if sys.platform.startswith("win") and \           not os.path.isfile(optionsPathname):            # If we are on Windows and still don't have an INI, default to the            # 'per-user' directory.            try:                from win32com.shell import shell, shellcon            except ImportError:                # We are on Windows, with no BAYESCUSTOMIZE set, no ini file                # in the current directory, and no win32 extensions installed                # to locate the "user" directory - seeing things are so lamely                # setup, it is worth printing a warning                print >>sys.stderr, "NOTE: We can not locate an INI file " \                      "for SpamBayes, and the Python for Windows extensions " \                      "are not installed, meaning we can't locate your " \                      "'user' directory.  An empty configuration file at " \                      "'%s' will be used." % optionsPathname.encode('mbcs')            else:                windowsUserDirectory = os.path.join(                        shell.SHGetFolderPath(0,shellcon.CSIDL_APPDATA,0,0),                        "SpamBayes", "Proxy")                try:                    if not os.path.isdir(windowsUserDirectory):                        os.makedirs(windowsUserDirectory)                except os.error:                    # unable to make the directory - stick to default.                    pass                else:                    optionsPathname = os.path.join(windowsUserDirectory,                                                   'bayescustomize.ini')                    # Not everyone is unicode aware - keep it a string.                    optionsPathname = optionsPathname.encode("mbcs")                    # If the file exists, then load it.                    if os.path.exists(optionsPathname):                        options.merge_file(optionsPathname)def get_pathname_option(section, option):    """Return the option relative to the path specified in the    gloabl optionsPathname, unless it is already an absolute path."""    filename = os.path.expanduser(options.get(section, option))    if os.path.isabs(filename):        return filename    return os.path.join(os.path.dirname(optionsPathname), filename)# Ideally, we should not create the objects at import time - but we have# done it this way forever!# We avoid having the options loading code at the module level, as then# the only way to re-read is to reload this module, and as at 2.3, that# doesn't work in a .zip file.load_options()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -