diff options
author | Isis Lovecruft <isis@torproject.org> | 2013-02-15 19:27:53 +0000 |
---|---|---|
committer | Isis Lovecruft <isis@torproject.org> | 2013-02-15 19:27:53 +0000 |
commit | d486c13af17133e2e5a2bfe6e5a862bfea6736ff (patch) | |
tree | 4f68c594a6e3ff072c9c886a076d03d679c2f3c7 /src/leap | |
parent | 02e84d4ac48294bdfea49678d59ebd410010e2a9 (diff) |
Module directory layout changes, with corresponding __init__.py changes.
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/__init__.py | 27 | ||||
-rw-r--r-- | src/leap/mx/__init__.py | 4 | ||||
-rw-r--r-- | src/leap/mx/util/__init__.py | 1 | ||||
-rw-r--r-- | src/leap/mx/util/config.py (renamed from src/leap/util/config.py) | 0 | ||||
-rw-r--r-- | src/leap/mx/util/exceptions.py (renamed from src/leap/util/exceptions.py) | 0 | ||||
-rw-r--r-- | src/leap/mx/util/log.py (renamed from src/leap/util/log.py) | 0 | ||||
-rw-r--r-- | src/leap/mx/util/net.py (renamed from src/leap/util/net.py) | 0 | ||||
-rw-r--r-- | src/leap/mx/util/version.py (renamed from src/leap/util/version.py) | 0 | ||||
-rwxr-xr-x | src/leap/start_mx.py (renamed from src/leap/mx.py) | 21 | ||||
-rw-r--r-- | src/leap/util/__init__.py | 50 |
10 files changed, 36 insertions, 67 deletions
diff --git a/src/leap/__init__.py b/src/leap/__init__.py index 99a951f..8846fbc 100644 --- a/src/leap/__init__.py +++ b/src/leap/__init__.py @@ -1,12 +1,25 @@ # -*- encoding: utf-8 -*- +__all__ = ['mx'] +__author__ = version.authors +__version__ = version.getVersion() + from leap import mx -from leap import util -from leap.util import version as mxversion +from leap.mx import util +from leap.mx.util import version + -__all__ = ['mx', 'util'] -__author__ = mxversion.authors -__version__ = mxversion.getVersion() +def _print_authors_nicely(): + if hasattr(version, 'authors'): + assert isinstance(version.authors, list) + if len(version.authors) > 0: + first = version.authors.pop() + __author__ = (" ".join(first[:2])) + if len(version.authors) > 0: + for auth in version.authors: + joined = " ".join(auth[:2]) + __author__ += ("\n%s" % joined) + -print "Authors: %s" % __author__ -print "Version: %s" % __version__ +print "Version: %s" % version.getVersion() +print "Authors: %s" % _print_authors_nicely() diff --git a/src/leap/mx/__init__.py b/src/leap/mx/__init__.py index 10d8ee7..507efee 100644 --- a/src/leap/mx/__init__.py +++ b/src/leap/mx/__init__.py @@ -1 +1,3 @@ -__all__ = ['alias_resolver', 'runner', 'tests'] +#from . import util + +__all__ = ['alias_resolver', 'runner', 'tests', 'couchdb'] diff --git a/src/leap/mx/util/__init__.py b/src/leap/mx/util/__init__.py new file mode 100644 index 0000000..c8448b0 --- /dev/null +++ b/src/leap/mx/util/__init__.py @@ -0,0 +1 @@ +__all__ = ['config', 'exceptions', 'log', 'net', 'version, storage'] diff --git a/src/leap/util/config.py b/src/leap/mx/util/config.py index 5bc5231..5bc5231 100644 --- a/src/leap/util/config.py +++ b/src/leap/mx/util/config.py diff --git a/src/leap/util/exceptions.py b/src/leap/mx/util/exceptions.py index 63b946c..63b946c 100644 --- a/src/leap/util/exceptions.py +++ b/src/leap/mx/util/exceptions.py diff --git a/src/leap/util/log.py b/src/leap/mx/util/log.py index ef54605..ef54605 100644 --- a/src/leap/util/log.py +++ b/src/leap/mx/util/log.py diff --git a/src/leap/util/net.py b/src/leap/mx/util/net.py index a4104d0..a4104d0 100644 --- a/src/leap/util/net.py +++ b/src/leap/mx/util/net.py diff --git a/src/leap/util/version.py b/src/leap/mx/util/version.py index 215876c..215876c 100644 --- a/src/leap/util/version.py +++ b/src/leap/mx/util/version.py diff --git a/src/leap/mx.py b/src/leap/start_mx.py index 60968bc..59556f0 100755 --- a/src/leap/mx.py +++ b/src/leap/start_mx.py @@ -16,24 +16,27 @@ import os, sys +package_source = "/src" application_name = "leap_mx" def __get_repo_dir__(): """Get the absolute path of the top-level repository directory.""" here = os.getcwd() - base = here.rsplit(application_name, 1)[0] - repo = os.path.join(base, application_name) - return repo + repo = here.rsplit(package_source, 1)[0] + leap = os.path.join(repo, package_source) + this = os.path.join(leap, application_name.replace('_', '/')) + return repo, leap, this ## Set the $PYTHONPATH: -src_dir = os.path.join(__get_repo_dir__(), 'src/') +repo, leap, this = __get_repo_dir__() +srcdir = os.path.join(repo, 'src/') sys.path[:] = map(os.path.abspath, sys.path) -sys.path.insert(0, src_dir) +sys.path.insert(0, leap) ## Now we should be able to import ourselves without installation: try: - from mx import runner - from util import log, version + from leap.mx import runner + from leap.mx.util import log, version except ImportError, ie: print "%s\nExiting..." % ie.message sys.exit(1) @@ -119,8 +122,8 @@ dependency_check = CheckRequirements(pipfile='pkg/mx-requirements.pip') try: from twisted.python import usage, runtime from twisted.internet import reactor -except: - print "the CheckRequirements class is broken!" +except ImportError, ie: + print "CheckRequirements class is broken!:", ie.message if __name__ == "__main__": diff --git a/src/leap/util/__init__.py b/src/leap/util/__init__.py deleted file mode 100644 index 35e1297..0000000 --- a/src/leap/util/__init__.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- encoding: utf-8 -*- -""" - mx/util/__init__.py - ------------------- - Initialization file for leap_mx utilities. Some miscellaneous things are - stored here also. -""" - - -class Storage(dict): - """ - A Storage object is like a dictionary except `obj.foo` can be used - in addition to `obj['foo']`. - - >>> o = Storage(a=1) - >>> o.a - 1 - >>> o['a'] - 1 - >>> o.a = 2 - >>> o['a'] - 2 - >>> del o.a - >>> o.a - None - """ - def __getattr__(self, key): - try: - return self[key] - except KeyError, k: - return None - - def __setattr__(self, key, value): - self[key] = value - - def __delattr__(self, key): - try: - del self[key] - except KeyError, k: - raise AttributeError, k - - def __repr__(self): - return '<Storage ' + dict.__repr__(self) + '>' - - def __getstate__(self): - return dict(self) - - def __setstate__(self, value): - for (k, v) in value.items(): - self[k] = v |