ATLAS Offline Software
MetaReaderPeeker.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 
4 __all__ = ['metadata']
5 
6 metadata = {}
7 
8 
9 def _setup():
10  from PyUtils.MetaReader import read_metadata
11 
12  from AthenaCommon.Logging import logging
13  msg = logging.getLogger('MetaReaderPeeker')
14 
15  global metadata
16 
17  from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
18  inFiles = athenaCommonFlags.FilesInput()
19 
20  from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
21  if athenaCommonFlags.isOnline() and (not inFiles or all([f.strip() == '' for f in inFiles])):
22  # set minimal items of inputFileSummary
23  metadata = {
24  'file_type':'BS',
25  'eventTypes':['IS_DATA','IS_ATLAS','IS_PHYSICS'],
26  'TagStreamsRef':''
27  }
28  else:
29  if len(inFiles) < 1:
30  msg.warning("No input files specified yet! Cannot do anything.")
31  return
32 
33 
34  for inFile in inFiles:
35 
36  metadatas = read_metadata(inFile, mode='peeker', promote=True, ignoreNonExistingLocalFiles=True)
37 
38  for foundFile, metadata in metadatas.items():
39 
40  metadata['file_name'] = inFile
41  if metadata.get("nentries"):
42  break
43  else:
44  continue # This make the previous break to exit from both for loops
45  break
46 
47  # if no nentries > 0 metadata is found, it will keep the last
48 
49 _setup()
python.MetaReader.read_metadata
def read_metadata(filenames, file_type=None, mode='lite', promote=None, meta_key_filter=None, unique_tag_info_values=True, ignoreNonExistingLocalFiles=False)
Definition: MetaReader.py:52
python.MetaReaderPeeker._setup
def _setup()
Definition: MetaReaderPeeker.py:9
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:64