~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/doc/api/transport.txt

  • Committer: John Arbash Meinel
  • Date: 2010-02-16 16:08:40 UTC
  • mfrom: (4797.2.15 2.1)
  • mto: (4797.2.16 2.1)
  • mto: This revision was merged to the branch mainline in revision 5037.
  • Revision ID: john@arbash-meinel.com-20100216160840-xwbpuu0v89gq8lej
Tags: bzr-2.1.0
bring in the latest 2.1 changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
The Transport API in bzrlib provides URL based access to network resources.
2
2
 
3
3
   >>> import os
 
4
   >>> import sys
4
5
   >>> from bzrlib.osutils import getcwd, dirname
 
6
   >>> from bzrlib.urlutils import local_path_from_url
5
7
   >>> import bzrlib.transport as transport
6
 
   >>> root = transport.get_transport("file:///")
 
8
   >>> if sys.platform == 'win32':
 
9
   ...     root = transport.get_transport('file:///C:/')
 
10
   ... else:
 
11
   ...     root = transport.get_transport('file:///')
7
12
   >>>
8
13
 
9
14
Each Transport instance represents a single logical directory.
10
15
 
11
16
   >>> dir = transport.get_transport(".")
12
 
   >>> dir.base == getcwd() + '/'
 
17
   >>> local_path_from_url(dir.base) == getcwd() + '/'
13
18
   True
14
19
 
15
20
You can change directories via the clone method:
16
21
 
17
22
   >>> parent = dir.clone('..')
18
 
   >>> parent.base == (dirname(getcwd()).rstrip('/') + '/')
 
23
   >>> local_path_from_url(parent.base) == (dirname(getcwd()).rstrip('/') + '/')
19
24
   True