[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-dev
Subject:    Re: [Python-Dev] The path module PEP
From:       VanL <news-nospam () northportal ! net>
Date:       2006-01-26 20:07:57
Message-ID: drba6h$dp0$1 () sea ! gmane ! org
[Download RAW message or body]

One other benefit that I neglected to put into the previous post - I was 
able to maintain separate cwd's for each tree.

An example of use:

Each tree has its own context, independent of the context of python:

 >>> local, local2 = fs.LocalTree(), fs.LocalTree()
 >>> local.pwd
'/home/targoz'
 >>> local2.pwd
'/home/targoz'
 >>> os.getcwd()
'/home/targoz'
 >>> local.chdir('..')
 >>> local2.chdir('www')
 >>> local.pwd
'/home'
 >>> local2.pwd
'/home/targoz/www'
 >>> os.getcwd()
'/home/targoz'

Remote trees have the same interface:

 >>> remote_login_data = {'username': 'targoz', 'password': 'my_pass', 
host': 'hostname.com'}
 >>> remote = fs.SSHTree(access=remote_login_data)
 >>> remote.pwd()
'/home/nportal'

Trees can interact, regardless of whether they are local or remote:

 >>> local2.listdir('files')
['myfile', 'otherfile.txt']
 >>> remote.listdir()
[]
 >>> localfile = local2.open(('targoz/myfile') # Opens a file-like object
 >>> remote.savefile(localfile, 'remote_name')
 >>> remote.listdir()
['myfile']

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev%40progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic