Package zeroinstall
[frames] | no frames]

Source Code for Package zeroinstall

 1  """ 
 2  The Python implementation of the Zero Install injector is divided into five sub-packages: 
 3   
 4   - L{zeroinstall.cmd} contains one module for each 0install sub-command (providing the shell-scripting interface) 
 5   - L{zeroinstall.injector} contains most of the interesting stuff for managing feeds, keys and downloads and for selecting versions 
 6   - L{zeroinstall.zerostore} contains low-level code for handling the implementation cache (where unpacked packages are stored) 
 7   - L{zeroinstall.gtkui} contains code for making GTK user-interfaces 
 8   - L{zeroinstall.support} contains helper code (not really specific to Zero Install) 
 9   
10  @copyright: (C) 2011, Thomas Leonard 
11  @see: U{http://0install.net} 
12   
13  @var _: a function for translating strings using the zero-install domain (for use internally by Zero Install) 
14  """ 
15   
16  version = '2.0' 
17   
18  import sys, logging 
19  if sys.version_info[0] > 2: 
20          try: 
21                  from gi.repository import GObject as gobject 
22          except ImportError: 
23                  gobject = None 
24  else: 
25          import gobject 
26  if gobject: 
27          gobject.threads_init() 
28   
29  logger = logging.getLogger('0install') 
30   
31  # Configure some basic logging, if the caller hasn't already done so. 
32  logging.basicConfig() 
33   
34  import gettext 
35  from os.path import dirname, join 
36   
37  try: 
38          localedir = None 
39          translation = gettext.translation('zero-install', fallback = False) 
40  except: 
41          localedir = join(dirname(dirname(__file__)), 'share', 'locale') 
42          translation = gettext.translation('zero-install', 
43                                  localedir = localedir, 
44                                  fallback = True) 
45  try: 
46          _ = translation.ugettext        # Python 2 
47  except AttributeError: 
48          _ = translation.gettext         # Python 3 
49   
50 -class SafeException(Exception):
51 """An exception that can be reported to the user without a stack trace. 52 The command-line interface's C{--verbose} option will display the full stack trace."""
53
54 -class NeedDownload(SafeException):
55 """Thrown if we tried to start a download and downloading is 56 disabled."""
57 - def __init__(self, url):
58 """@type url: str""" 59 Exception.__init__(self, _("Would download '%s'") % url)
60
61 -class DryRun(SafeException):
62 """We can't do something because this is a dry run (--dry-run). 63 @since: 1.14"""
64