[PATCH] Re: Move __version__ definition etc. into __init__.py
Nicolas Sebrecht
nicolas.s-dev at laposte.net
Mon Dec 20 18:45:14 GMT 2010
I think the title is lying because __version__ didn't exist.
On Mon, Dec 20, 2010 at 01:28:17PM +0100, Sebastian Spaeth wrote:
>
> Move central definitions into __init__.py and do away with version.py.
> __init__.py is where things like __VERSION__ are usually defined.
>
> Adapt all code to use the new locations.
You don't explain _why_ this is a _good_ change. What is "usually
defined" might not be approppriate for us.
> Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
> ---
> This is the next patch in my line of code clean ups. AFAIK it
> simplifies by doing away with a file that is really not needed. Such
> definitions are usually kept in __init__.py. This is also the central
> place in which version numbers should be kept and bumped AFAIK.
>
> offlineimap/__init__.py | 20 +++++++++++++++++++-
> offlineimap/folder/IMAP.py | 4 ++--
> offlineimap/init.py | 7 +++++--
> offlineimap/ui/Curses.py | 13 +++++++------
> offlineimap/ui/UIBase.py | 6 +++---
> offlineimap/version.py | 35 -----------------------------------
> setup.py | 12 ++++++------
> 7 files changed, 42 insertions(+), 55 deletions(-)
> delete mode 100644 offlineimap/version.py
>
> diff --git a/offlineimap/__init__.py b/offlineimap/__init__.py
> index c36246c..ee03c40 100644
> --- a/offlineimap/__init__.py
> +++ b/offlineimap/__init__.py
> @@ -1,5 +1,23 @@
> from offlineimap.init import OfflineImap
> +__all__ = ['OfflineImap']
> +
> +__productname__ = 'OfflineIMAP'
> +__version__ = "6.3.1"
> +__copyright__ = "Copyright (C) 2002 - 2010 John Goerzen"
> +__author__ = "John Goerzen"
> +__author_email__= "john at complete.org"
> +__description__ = "Disconnected Universal IMAP Mail Synchronization/Reader Support"
> +__bigcopyright__ = """%(__productname__)s %(__version__)s
> +%(__copyright__)s <%(__author_email__)s>""" % locals()
> +
> +banner = __bigcopyright__ + """
> +
> +This software comes with ABSOLUTELY NO WARRANTY; see the file
> +COPYING for details. This is free software, and you are welcome
> +to distribute it under the conditions laid out in COPYING."""
> +
> +__homepage__ = "http://github.com/spaetz/offlineimap"
Hugh?
> +__license__ = "Licensed under the GNU GPL v2+ (v2 or any later version)."
>
> -__all__ = ['ui', 'folder', 'repository', 'mbnames', 'threadutil', 'init']
>
>
> diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
> index 927c5f4..6fef048 100644
> --- a/offlineimap/folder/IMAP.py
> +++ b/offlineimap/folder/IMAP.py
> @@ -18,9 +18,9 @@
>
> from Base import BaseFolder
> import imaplib
> +import offlineimap
> from offlineimap import imaputil, imaplibutil
Imported twice?
> from offlineimap.ui import UIBase
> -from offlineimap.version import versionstr
> import rfc822, time, string, random, binascii, re
> from StringIO import StringIO
> from copy import copy
> @@ -226,7 +226,7 @@ class IMAPFolder(BaseFolder):
> headervalue += binascii.hexlify(self.getname())
> headervalue += '-%d-' % long(time.time())
> headervalue += str(self.randomgenerator.random()).replace('.', '')
> - headervalue += '-v' + versionstr
> + headervalue += '-v' + offlineimap.__version__
> return (headername, headervalue)
>
> def savemessage_addheader(self, content, headername, headervalue):
> diff --git a/offlineimap/init.py b/offlineimap/init.py
> index 4a7c67a..30a31ae 100644
> --- a/offlineimap/init.py
> +++ b/offlineimap/init.py
> @@ -59,7 +59,10 @@ class OfflineImap:
> def run(self):
> """Parse the commandline and invoke everything"""
>
> - parser = OptionParser()
> + parser = OptionParser(version=offlineimap.banner,
> + description="%s.\n\n%s" %
> + (offlineimap.__copyright__,
> + offlineimap.__license__))
> parser.add_option("-1",
> action="store_true", dest="singlethreading",
> default=False,
> @@ -90,7 +93,7 @@ class OfflineImap:
> parser.add_option("-c", dest="configfile", metavar="FILE",
> default="~/.offlineimaprc",
> help="Specifies a configuration file to use in lieu of "
> - "the default, ~/.offlineimaprc.")
> + "%default.")
>
> parser.add_option("-d", dest="debugtype", metavar="type1,[type2...]",
> help=
> diff --git a/offlineimap/ui/Curses.py b/offlineimap/ui/Curses.py
> index 285d3af..24c1534 100644
> --- a/offlineimap/ui/Curses.py
> +++ b/offlineimap/ui/Curses.py
> @@ -20,7 +20,8 @@ from Blinkenlights import BlinkenBase
> from UIBase import UIBase
> from threading import *
> import thread, time, sys, os, signal, time
> -from offlineimap import version, threadutil
> +import offlineimap
> +from offlineimap import threadutil
Ditto.
--
Nicolas Sebrecht
More information about the OfflineIMAP-project
mailing list