2 from FWCore.ParameterSet.pfnInPath
import pfnInPath
7 """ Ensure that everything is done for path to exist 9 - path: String that can be both directory and file 11 - general: environmental variables are expanded 12 - directory: is checked to exist 13 - file: is checked to exist with backup directory being searched in cms-data 16 if not isinstance(path, str):
22 protocol = path.split(
"://")[0]+
"://" 23 path_s = path.split(
"://")[1].
split(os.sep)
25 path_s = path.split(os.sep)
29 for ipart,part
in enumerate(path_s):
31 if part.startswith(
'$'):
33 path_d_s.append(os.environ[env_var])
36 placeholderIdx.append(ipart)
43 path_d = os.path.join(*path_d_s)
44 if len(placeholderIdx) > 0:
45 path_to_check = os.path.join(*path_d_s[:placeholderIdx[0]])
47 path_to_check = path_d
50 if path.startswith(os.sep):
51 path_d = os.sep + path_d
52 path_to_check = os.sep + path_to_check
55 if not os.path.exists(path_to_check)
and "." in os.path.splitext(path_to_check)[-1]:
59 return _file.split(
":")[-1]
62 if protocol !=
"": path_d = protocol + path_d
71 Generate all keys for nested dictionary 73 if hasattr(var,
'items'):
74 for k, v
in var.items():
75 if isinstance(v, dict):
78 elif isinstance(v, list):
88 """Perform effective search for keys in nested dictionary 89 - if key is found, corresponding value is "digested" 90 - generator is returned for printout purpose only 91 - original var is overwritten 93 if hasattr(var,
'items'):
98 for k, v
in var.items():
100 if isinstance(v,list):
101 var[k] = [alt(_v)
for _v
in v]
105 if isinstance(v, dict):
108 elif isinstance(v, list):
def find_and_change(keys, var, alt=digest_path)
def replace(string, replacements)
def split(sequence, size)