63def filelist(files, prefix=None):
64 """
65 lists CASTOR/EOS name server directory/file entries.
66 If path is a directory, filelist lists the entries in the directory;
67 they are sorted alphabetically.
68
69 `files` specifies the CASTOR/EOS pathname.
70 `prefix` specifies the prefix one wants to prepend to the path found.
71 (e.g. prefix='root://castoratlas/' or 'root://eosatlas.cern.ch//')
72 if prefix=True it will determin the prefix based on the pathname
73
74 ex:
75 filelist('/castor/cern.ch/atlas/*')
76 filelist('/castor/cern.ch/atl*/foo?[bar]/*.pool.root.?')
77 filelist('/eos/atlas/*', prefix='root://eosatlas.cern.ch/')
78 filelist('/castor/cern.ch/atlas/*', prefix=True)
79 """
80
81 path, fname = os.path.split(files)
82 path = _rationalise(path)
83
84 if ( path.count('*') > 0 or path.count('?') > 0 or
85 path.count('[') > 0 or path.count(']') > 0 ) :
86 paths = ls(path)
87 return sum([ls(os.path.join(p,fname))
88 for p in paths], [])
89
90 mgr = storageManager(path)
91
92 try:
93 flist = subprocess.check_output(mgr.ls % path, shell=
True).
split()
94 except subprocess.CalledProcessError as err:
96 return []
97
98 if not (os.path.basename(files) in ['', '*']):
99 pattern = fnmatch.translate(os.path.basename(files))
100 flist = filter(lambda x: re.search(pattern, x), flist)
101
102 if prefix:
103 if isinstance(prefix, str):
104 return [os.path.join(prefix+path, p) for p in flist]
105 else:
106 return [os.path.join(mgr.prefix+path, p) for p in flist]
107 else:
108 return [os.path.join(path, p) for p in flist]
109
110@deprecated("EOS is mounted on /eos with fuse, so you probably don't need this abstraction")
std::vector< std::string > split(const std::string &s, const std::string &t=":")