ATLAS Offline Software
Functions
meta-diff Namespace Reference

Functions

def main ()
 

Function Documentation

◆ main()

def meta-diff.main ( )
Handle command line arguments and call meta_diff

Definition at line 18 of file meta-diff.py.

18 def main():
19  """Handle command line arguments and call meta_diff"""
20 
21  parser = argparse.ArgumentParser(
22  description="Compare the metadata content of two files"
23  )
24 
25  parser.add_argument(
26  "files",
27  nargs=2,
28  metavar="FILE",
29  help="The names of two files to compare",
30  )
31 
32  parser.add_argument(
33  "-v",
34  "--verbose",
35  action="store_true",
36  help="print detailed output on screen",
37  )
38 
39  parser.add_argument(
40  "-s",
41  "--ordered",
42  action="store_true",
43  help="When comparing lists, check the element order too.",
44  )
45 
46  parser.add_argument(
47  "-r",
48  "--regex",
49  action="store_true",
50  help="Allows filtering by regex instead of by plain string",
51  )
52 
53  parser.add_argument(
54  "-k",
55  "--key-only",
56  action="store_true",
57  help="Show only the keys and not the difference",
58  )
59 
60  parser.add_argument(
61  "-d",
62  "--drop",
63  nargs="+",
64  default=None,
65  metavar="KEY",
66  help="Keys to drop from metadata retrieved from file. Separe nested dictionary keys using '.'. An '*' matches any key.",
67  )
68 
69  parser.add_argument(
70  "-m",
71  "--mode",
72  default="full",
73  metavar="MODE",
74  type=str,
75  choices=["tiny", "lite", "full", "peeker"],
76  help="""\
77  This flag provides the user capability to select the amount of
78  metadata retrieved. There are four options:
79  tiny (only those values used in PyJobTransforms),
80  lite
81  peeker
82  and full ( all available data found)
83  """,
84  )
85 
86  parser.add_argument(
87  "-t",
88  "--type",
89  default=None,
90  metavar="TYPE",
91  type=str,
92  choices=["POOL", "BS"],
93  help="""\
94  The file type of the input filename. By default, it tries to
95  determine itself the file type of the input.
96  """,
97  )
98 
99  parser.add_argument(
100  "-f",
101  "--filter",
102  default=[],
103  metavar="FILTER",
104  nargs="+",
105  type=str,
106  help="Expression to select specific metadata fields to retrieve.",
107  )
108 
109  parser.add_argument(
110  "-x",
111  "--diff-format",
112  default="simple",
113  type=str,
114  choices=["simple", "diff"],
115  help="Switch between 'simple' or 'diff' style differences ",
116  )
117 
118  parser.add_argument(
119  "--promote",
120  default=None,
121  type=bool,
122  help="Force promotion or not of the metadata keys ",
123  )
124 
125  parser.add_argument(
126  "--ignoreTrigger",
127  action='store_true',
128  help="Ignore trigger metadata",
129  )
130 
131  args = parser.parse_args()
132 
133  if len(args.files) != 2:
134  print("you must supply two files to compare")
135  sys.exit(1)
136 
137  for file_name in args.files:
138  if not os.path.exists(file_name):
139  print("File does not exists: {}".format(file_name))
140  sys.exit(1)
141 
142 
143  diff = meta_diff(
144  args.files,
145  verbose=args.verbose,
146  ordered=args.ordered,
147  drop=args.drop,
148  mode=args.mode,
149  meta_key_filter=args.filter,
150  file_type=args.type,
151  promote=args.promote,
152  diff_format=args.diff_format,
153  regex=args.regex,
154  key_only=args.key_only,
155  ignore_trigger=args.ignoreTrigger,
156  )
157 
158 
159  if diff:
160  print("\n".join(diff))
161  sys.exit(1)
162 
163  sys.exit(0)
164 
165 
vtune_athena.format
format
Definition: vtune_athena.py:14
meta-diff.main
def main()
Definition: meta-diff.py:18
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.MetaDiff.meta_diff
def meta_diff(files, verbose=False, ordered=False, drop=None, mode="lite", meta_key_filter=None, file_type=None, promote=False, diff_format="simple", regex=False, key_only=False, ignore_trigger=False)
Definition: MetaDiff.py:279