root/galaxy-central/eggs/twill-0.9-py2.6.egg/twill/extensions/dirstack.py @ 3

リビジョン 3, 1.0 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2Extension functions for manipulating the current working directory (cwd).
3
4Commands:
5
6   chdir -- push the cwd onto the directory stack & change to the new location.
7   popd  -- change to the last directory on the directory stack.
8"""
9import os
10
11_dirstack = []
12
13def chdir(where):
14    """
15    >> chdir <where>
16
17    Change to the new location, after saving the current directory onto
18    the directory stack.  The global variable __dir__ is set to the cwd.
19    """
20    from twill import commands
21   
22    cwd = os.getcwd()
23    _dirstack.append(cwd)
24    print cwd
25
26    os.chdir(where)
27    print>>commands.OUT, 'changed directory to "%s"' % (where,)
28
29    commands.setglobal('__dir__', where)
30
31def popd():
32    """
33    >> popd
34
35    Change back to the last directory on the directory stack.  The global
36    variable __dir__ is set to the cwd.
37    """
38    from twill import commands
39   
40    where = _dirstack.pop()
41    os.chdir(where)
42    print>>commands.OUT, 'popped back to directory "%s"' % (where,)
43
44    commands.setglobal('__dir__', where)
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。