From 4d2809c9a46ec5676f2a08457609f559d910785f Mon Sep 17 00:00:00 2001
From: Jiří Pinkava <j-pi@seznam.cz>
Date: Sun, 26 Jun 2016 13:04:39 +0200
Subject: filter: replace OptionParser by ArgumentParser for gr-utils and
 gr-qtgui

---
 gr-utils/python/utils/gr_plot_float | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

(limited to 'gr-utils/python/utils/gr_plot_float')

diff --git a/gr-utils/python/utils/gr_plot_float b/gr-utils/python/utils/gr_plot_float
index 22806e48ae..faf8106d70 100755
--- a/gr-utils/python/utils/gr_plot_float
+++ b/gr-utils/python/utils/gr_plot_float
@@ -26,29 +26,26 @@ except ImportError:
     print "Please install SciPy to run this script (http://www.scipy.org/)"
     raise SystemExit, 1
 
-from optparse import OptionParser
+from argparse import ArgumentParser
 from gnuradio.plot_data import plot_data
 
 def main():
-    usage="%prog: [options] input_filenames"
     description = "Takes a GNU Radio floating point binary file and displays the samples versus time. You can set the block size to specify how many points to read in at a time and the start position in the file. By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
 
-    parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
-    parser.add_option("-B", "--block", type="int", default=1000,
-                      help="Specify the block size [default=%default]")
-    parser.add_option("-s", "--start", type="int", default=0,
-                      help="Specify where to start in the file [default=%default]")
-    parser.add_option("-R", "--sample-rate", type="float", default=1.0,
-                      help="Set the sampler rate of the data [default=%default]")
+    parser = ArgumentParser(conflict_handler="resolve", description=description)
+    parser.add_argument("-B", "--block", type=int, default=1000,
+            help="Specify the block size [default=%(default)r]")
+    parser.add_argument("-s", "--start", type=int, default=0,
+            help="Specify where to start in the file [default=%(default)r]")
+    parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+            help="Set the sampler rate of the data [default=%(default)r]")
+    parser.add_argument("file", metavar="FILE", nargs='+',
+            help="Input file with samples")
 
-    (options, args) = parser.parse_args ()
-    if len(args) < 1:
-        parser.print_help()
-        raise SystemExit, 1
-    filenames = args
+    args = parser.parse_args()
 
     datatype=scipy.float32
-    dc = plot_data(datatype, filenames, options)
+    dc = plot_data(datatype, args.file, args)
 
 if __name__ == "__main__":
     try:
-- 
cgit v1.2.3