ATLAS Offline Software
Functions
python.TrigARTUtils Namespace Reference

Functions

def package_prefix (package)
 
def duplicate_filename (list, filename)
 
def find_scripts (patterns)
 
def remember_cwd ()
 
def first_existing_file (file_list)
 
def newest_file (pattern)
 

Function Documentation

◆ duplicate_filename()

def python.TrigARTUtils.duplicate_filename (   list,
  filename 
)

Definition at line 23 of file TrigARTUtils.py.

23 def duplicate_filename(list, filename):
24  for path in list:
25  if os.path.basename(path) == filename:
26  return True
27  return False
28 
29 

◆ find_scripts()

def python.TrigARTUtils.find_scripts (   patterns)

Definition at line 30 of file TrigARTUtils.py.

30 def find_scripts(patterns):
31  scripts = []
32  for path in os.environ['PATH'].split(os.pathsep):
33  try:
34  files = os.listdir(path)
35  except OSError:
36  continue
37  for filename in files:
38  matched = True
39  for patt in patterns:
40  if re.search(patt, filename) is None:
41  matched = False
42  break
43  if matched and not duplicate_filename(scripts, filename):
44  scripts.append(os.path.join(path, filename))
45  scripts.sort()
46  return scripts
47 
48 
49 @contextmanager

◆ first_existing_file()

def python.TrigARTUtils.first_existing_file (   file_list)
Returns the first file name from the list which corresponds to an existing file.
Returns None if none of the files in the list exist.

Definition at line 59 of file TrigARTUtils.py.

59 def first_existing_file(file_list):
60  '''
61  Returns the first file name from the list which corresponds to an existing file.
62  Returns None if none of the files in the list exist.
63  '''
64  for file_name in file_list:
65  if os.path.isfile(file_name):
66  return file_name
67  return None
68 
69 

◆ newest_file()

def python.TrigARTUtils.newest_file (   pattern)
Returns the newest file (by modification date) in the current directory
with a name matching the pattern. Returns None if no file is matched.

Definition at line 70 of file TrigARTUtils.py.

70 def newest_file(pattern):
71  '''
72  Returns the newest file (by modification date) in the current directory
73  with a name matching the pattern. Returns None if no file is matched.
74  '''
75  all_files = os.listdir('.')
76  rx = re.compile(pattern)
77  matched_files = [f for f in all_files if re.search(rx, f)]
78  if not matched_files:
79  return None
80  matched_files.sort(key=lambda f: os.stat(f).st_mtime)
81  return matched_files[-1]

◆ package_prefix()

def python.TrigARTUtils.package_prefix (   package)
Returns a prefix included in names of all tests from the given package

Definition at line 12 of file TrigARTUtils.py.

12 def package_prefix(package):
13  '''Returns a prefix included in names of all tests from the given package'''
14  from TrigValTools.TrigValSteering.Common import package_prefix_dict
15  if package == 'ALL':
16  return '({})'.format('|'.join(package_prefix_dict.values()))
17  elif package in package_prefix_dict.keys():
18  return package_prefix_dict[package]
19  else:
20  return None
21 
22 

◆ remember_cwd()

def python.TrigARTUtils.remember_cwd ( )
Simple pushd/popd replacement from https://stackoverflow.com/a/169112

Definition at line 50 of file TrigARTUtils.py.

50 def remember_cwd():
51  '''Simple pushd/popd replacement from https://stackoverflow.com/a/169112'''
52  curdir = os.getcwd()
53  try:
54  yield
55  finally:
56  os.chdir(curdir)
57 
58 
vtune_athena.format
format
Definition: vtune_athena.py:14
python.TrigARTUtils.package_prefix
def package_prefix(package)
Definition: TrigARTUtils.py:12
python.TrigARTUtils.newest_file
def newest_file(pattern)
Definition: TrigARTUtils.py:70
python.TrigARTUtils.find_scripts
def find_scripts(patterns)
Definition: TrigARTUtils.py:30
python.TrigARTUtils.first_existing_file
def first_existing_file(file_list)
Definition: TrigARTUtils.py:59
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.TrigARTUtils.duplicate_filename
def duplicate_filename(list, filename)
Definition: TrigARTUtils.py:23
python.TrigARTUtils.remember_cwd
def remember_cwd()
Definition: TrigARTUtils.py:50
Trk::split
@ split
Definition: LayerMaterialProperties.h:38