Fix: update tests for --no-intersection
[deliverable/lttng-analyses.git] / parser_generator.py
index 10e8a05f258531a99594403678e358291775c35a..7e05dc3702df8ecb4d952e2910343fa497b4924b 100755 (executable)
@@ -1,16 +1,8 @@
 #!/usr/bin/env python3
 #
-# Copyright 2014 Julien Desfossez <jdesfossez@efficios.com>
+# The MIT License (MIT)
 #
-# This script takes a trace in argument and generates a Python parser ready to
-# process the events (and all the fields) of the trace. It is used to generate
-# all the boilerplate required to create an analysis script of a CTF trace in
-# Python and allow the user to focus on the core logic of the analysis.
-#
-# The default resulting script can process all the events of the trace, and
-# print all the fields for each event (except if you pass -q/--quiet). At the
-# end of the trace, it displays also global statistics about the number of each
-# event encountered.
+# Copyright (C) 2015 - Julien Desfossez <jdesfossez@efficios.com>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
 #
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
 
 import sys
 import os
@@ -117,6 +117,8 @@ def gen_parser(handle, fd, args):
                         fname = "_in"
                     if fname == "event":
                         fname = "_event"
+                    if fname == "from":
+                        fname = "_from"
                     fd.write("        %s = event[\"%s\"]\n" % (fname,
                              field.name))
                     fmt_str = fmt_str + field.name + " = %s, "
@@ -124,13 +126,13 @@ def gen_parser(handle, fd, args):
             fd.write("\n        self.event_count[event.name] += 1\n")
             if not args.quiet:
                 fd.write("        print(\"%s }\" %% (%s))\n\n" %
-                        (fmt_str[0:-2], fmt_fields[0:-1]))
+                         (fmt_str[0:-2], fmt_fields[0:-1]))
 
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(description='Trace parser generator')
     parser.add_argument('path', metavar="<path/to/trace>", help='Trace path')
-    parser.add_argument('-o', '--output', type=str, default=0,
+    parser.add_argument('-o', '--output', type=str,
                         metavar="<output-script-name>",
                         help='Output script name')
     parser.add_argument('-q', '--quiet', action="store_true",
@@ -142,7 +144,7 @@ if __name__ == "__main__":
     if handle is None:
         sys.exit(1)
 
-    if args.output == 0:
+    if not args.output:
         output = "generated-parser.py"
     else:
         output = args.output
This page took 0.025252 seconds and 5 git commands to generate.