From 458d17bd2b801e5dc20943604679acc6c55e4838 Mon Sep 17 00:00:00 2001 From: Vakho Tsulaia <vakhtang.tsulaia@cern.ch> Date: Sat, 20 Apr 2024 00:34:27 +0200 Subject: [PATCH] PoolFile: completed cleanup of the dependency on AthFile Removed unused functions: * _guess_file_type() in AthFile * extract_stream_names() in PoolFile.py --- Tools/PyUtils/python/AthFile/__init__.py | 38 ------------------------ Tools/PyUtils/python/PoolFile.py | 17 ----------- 2 files changed, 55 deletions(-) diff --git a/Tools/PyUtils/python/AthFile/__init__.py b/Tools/PyUtils/python/AthFile/__init__.py index c98abc15251e..0be996f426b2 100644 --- a/Tools/PyUtils/python/AthFile/__init__.py +++ b/Tools/PyUtils/python/AthFile/__init__.py @@ -50,7 +50,6 @@ class ModuleFacade(types.ModuleType): self.__dict__[ '__file__' ] = module.__file__ self.__dict__['_impl'] = _impl - self.__dict__['_guess_file_type'] = _guess_file_type self.__dict__['server'] = _impl.g_server @@ -145,43 +144,6 @@ class ModuleFacade(types.ModuleType): pass # class ModuleFacade -### - -def _guess_file_type(fname, msg): - """guess the type of an input file (bs,rdo,esd,aod,...) - """ - input_type = None - import PyUtils.AthFile as af - try: - file_type,file_name = af.ftype(fname) - except Exception: - raise # for now - if file_type == 'bs': - input_type = 'bs' - elif file_type == 'pool': - import PyUtils.PoolFile as pf - stream_names = pf.extract_stream_names(fname) - stream_names = [s.lower() for s in stream_names] - if len(stream_names) > 1: - msg.warning('got many stream names: %r', stream_names) - msg.warning('only considering the 1st one...') - elif len(stream_names) <= 0: - msg.warning('got an empty list of stream names') - raise SystemExit(1) - stream_name = stream_names[0] - input_type = { - 'stream1': 'rdo', - 'streamesd' : 'esd', - 'streamaod' : 'aod', - # FIXME: TODO: TAG, DPD - }.get(stream_name, 'aod') - - else: - msg.error('unknown file type (%s) for file [%s]', - file_type, file_name) - return input_type - - ### exec at import ------------------------------------------------------------ import sys sys.modules[ __name__ ] = ModuleFacade( sys.modules[ __name__ ] ) diff --git a/Tools/PyUtils/python/PoolFile.py b/Tools/PyUtils/python/PoolFile.py index 289ea0bd0cfc..4cfba2fef57f 100644 --- a/Tools/PyUtils/python/PoolFile.py +++ b/Tools/PyUtils/python/PoolFile.py @@ -10,7 +10,6 @@ __author__ = "Sebastien Binet <binet@cern.ch>" ### --- data ------------------------------------------------------------------ __all__ = [ 'PoolFileCatalog', - 'extract_stream_names', 'PoolOpts', 'extract_items', 'PoolRecord', @@ -244,22 +243,6 @@ class PoolFileCatalog(object): pass -def extract_stream_names(fname): - """find the stream names ('StreamESD', 'StreamAOD',...) contained in a - given POOL file - @params: - `fname` the filename of the POOL file to inspect (can be LFN or PFN) - - example: - >>> import PyUtils.PoolFile as pf - >>> streams = pf.extract_stream_names ('ESD.pool.root') - >>> print streams - ['StreamESD'] - """ - import PyUtils.AthFile as af - f = af.fopen(fname) - return f.fileinfos['stream_names'] - class PoolOpts(object): # default names of APR file storage elements # copied here from RootUtils/APRDefaults.h for performance (as the first dictionary access takes 7 sec) -- GitLab