-
Notifications
You must be signed in to change notification settings - Fork 0
/
rootls.py
executable file
·40 lines (31 loc) · 894 Bytes
/
rootls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/env python
def ls(fname,curdir=''):
rfile = ROOT.TFile(fname,'READ')
if curdir:
tdir = rfile.Get(curdir)
curdir=curdir.rstrip('/')+'/'
else:
tdir = rfile
for tkey in tdir.GetListOfKeys():
toprint = curdir+tkey.GetName()
if tkey.GetClassName().count('Directory'):
toprint += '/'
print toprint
if __name__=="__main__":
import sys, os
if not sys.stdout.isatty():
# remember the original setting
oldTerm = os.environ['TERM']
os.environ['TERM'] = ''
import ROOT
# restore the orignal TERM setting
os.environ['TERM'] = oldTerm
del oldTerm
else:
import ROOT
#print sys.argv
try:
subdir = '/'.join(sys.argv[2].split('/')[:-1])
ls(sys.argv[1],subdir)
except IndexError:
ls(sys.argv[1])