~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/directory_service.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-04-08 06:17:41 UTC
  • mfrom: (4797.33.16 apport)
  • Revision ID: pqm@pqm.ubuntu.com-20100408061741-m7vl6z97vu33riv7
(robertc) Make sure ExecutablePath and InterpreterPath are set in
        Apport. (Martin Pool, James Westby, lp:528114)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Directory service registration and usage.
18
18
 
21
21
"""
22
22
 
23
23
from bzrlib import errors, registry
 
24
from bzrlib.lazy_import import lazy_import
 
25
lazy_import(globals(), """
24
26
from bzrlib.branch import Branch
 
27
from bzrlib import urlutils
 
28
""")
 
29
 
25
30
 
26
31
class DirectoryServiceRegistry(registry.Registry):
27
32
    """This object maintains and uses a list of directory services.
72
77
            'push': branch.get_push_location,
73
78
            'this': lambda: branch.base
74
79
        }
 
80
        parts = url.split('/', 1)
 
81
        if len(parts) == 2:
 
82
            name, extra = parts
 
83
        else:
 
84
            (name,) = parts
 
85
            extra = None
75
86
        try:
76
 
            method = lookups[url[1:]]
 
87
            method = lookups[name[1:]]
77
88
        except KeyError:
78
89
            raise errors.InvalidLocationAlias(url)
79
90
        else:
80
91
            result = method()
81
92
        if result is None:
82
93
            raise errors.UnsetLocationAlias(url)
 
94
        if extra is not None:
 
95
            result = urlutils.join(result, extra)
83
96
        return result
84
97
 
85
98
directories.register(':', AliasDirectory,