[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 05/08: grcc: replace OptionParser by Argume
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 05/08: grcc: replace OptionParser by ArgumentParser |
Date: |
Wed, 11 May 2016 17:41:08 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch next
in repository gnuradio.
commit d6082662fdcf65e5fa2de83ddfda91c9dd9b2ed1
Author: Jiří Pinkava <address@hidden>
Date: Tue Nov 24 11:32:57 2015 +0100
grcc: replace OptionParser by ArgumentParser
---
gr-utils/python/utils/grcc | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/gr-utils/python/utils/grcc b/gr-utils/python/utils/grcc
index 82db543..776af79 100755
--- a/gr-utils/python/utils/grcc
+++ b/gr-utils/python/utils/grcc
@@ -22,7 +22,7 @@
import os
import sys
-from optparse import OptionParser
+from argparse import ArgumentParser
import warnings
warnings.simplefilter('ignore')
@@ -57,28 +57,25 @@ class GRCC:
def main():
- usage="%prog: [options] filename"
description = "Compiles a GRC file (.grc) into a GNU Radio Python program.
The program is stored in ~/.grc_gnuradio by default, but this location can be
changed with the -d option."
- parser = OptionParser(conflict_handler="resolve", usage=usage,
description=description)
- parser.add_option("-d", "--directory", type="string",
default='{0}/.grc_gnuradio/'.format(os.environ["HOME"]),
- help="Specify the directory to output the compile
program [default=%default]")
- parser.add_option("-e", "--execute", action="store_true", default=False,
- help="Run the program after compiling
[default=%default]")
- (options, args) = parser.parse_args ()
-
- if len(args) != 1:
- sys.stderr.write("Please specify a GRC file name to compile.\n")
- sys.exit(1)
+ parser = ArgumentParser(description=description)
+ parser.add_argument("-d", "--directory",
+ default='{0}/.grc_gnuradio/'.format(os.environ["HOME"]),
+ help="Specify the directory to output the compile program
[default=%(default)s]")
+ parser.add_argument("-e", "--execute", action="store_true", default=False,
+ help="Run the program after compiling [default=%(default)s]")
+ parser.add_argument('grc_file', metavar="GRC_FILE", help=".grc file to
compile")
+ args = parser.parse_args()
try:
- g = GRCC(args[0], options.directory + "/")
+ g = GRCC(args.grc_file, args.directory + "/")
except Exception as e:
sys.stderr.write(str(e) + "\n")
sys.stderr.write("Error during file compilation.\n")
sys.exit(1)
- if options.execute:
+ if args.execute:
g.exec_program()
- [Commit-gnuradio] [gnuradio] branch next updated (493a19e -> 02b6805), git, 2016/05/11
- [Commit-gnuradio] [gnuradio] 01/08: examples: affinity_set use ArgParse, git, 2016/05/11
- [Commit-gnuradio] [gnuradio] 07/08: Merge branch 'master' into next, git, 2016/05/11
- [Commit-gnuradio] [gnuradio] 08/08: Merge remote-tracking branch 'pinkavaj/argparse-01' into next, git, 2016/05/11
- [Commit-gnuradio] [gnuradio] 03/08: grc: gnuradio-companion use ArgumentParser, git, 2016/05/11
- [Commit-gnuradio] [gnuradio] 06/08: examples: run_synthetic.py use ArgumentParser, git, 2016/05/11
- [Commit-gnuradio] [gnuradio] 04/08: grc: flow graph templates use ArgumentParser, git, 2016/05/11
- [Commit-gnuradio] [gnuradio] 02/08: examples: plot_flops use ArgumentParser, git, 2016/05/11
- [Commit-gnuradio] [gnuradio] 05/08: grcc: replace OptionParser by ArgumentParser,
git <=