~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2009-09-07 03:08:30 UTC
  • mto: This revision was merged to the branch mainline in revision 4690.
  • Revision ID: robertc@robertcollins.net-20090907030830-rf59kt28d550eauj
Milestones language tightning, internal consistency.

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
 
5
   >>> from bzrlib.osutils import getcwd, dirname
 
6
   >>> from bzrlib.urlutils import local_path_from_url
4
7
   >>> import bzrlib.transport as transport
5
 
   >>> 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:///')
6
12
   >>>
7
13
 
8
14
Each Transport instance represents a single logical directory.
9
15
 
10
16
   >>> dir = transport.get_transport(".")
11
 
   >>> dir.base == os.getcwdu() + '/'
 
17
   >>> local_path_from_url(dir.base) == getcwd() + '/'
12
18
   True
13
19
 
14
20
You can change directories via the clone method:
15
21
 
16
22
   >>> parent = dir.clone('..')
17
 
   >>> parent.base == os.path.dirname(os.getcwdu()) + '/'
 
23
   >>> local_path_from_url(parent.base) == (dirname(getcwd()).rstrip('/') + '/')
18
24
   True