[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/08: grc: flow graph templates use Argume
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/08: grc: flow graph templates use 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 ed99f139c22988d9c7b0cccd7e8da01407919460
Author: Jiří Pinkava <address@hidden>
Date: Sat Oct 10 21:28:23 2015 +0200
grc: flow graph templates use ArgumentParser
---
grc/blocks/options.xml | 4 ++--
grc/blocks/parameter.xml | 4 +++-
grc/core/generator/flow_graph.tmpl | 12 ++++++------
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml
index 937cfe8..bb96f29 100644
--- a/grc/blocks/options.xml
+++ b/grc/blocks/options.xml
@@ -20,8 +20,8 @@ from PyQt4 import Qt
import sys
#end if
#if not $generate_options().startswith('hb')
-from optparse import OptionParser
-from gnuradio.eng_option import eng_option
+from argparse import ArgumentParser
+from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
#end if</import>
<make></make>
diff --git a/grc/blocks/parameter.xml b/grc/blocks/parameter.xml
index e35b8f4..0c10da4 100644
--- a/grc/blocks/parameter.xml
+++ b/grc/blocks/parameter.xml
@@ -57,7 +57,9 @@
<name>String</name>
<key>string</key>
<opt>type:string</opt>
- </option>
+ </option>
+ <!-- Do not forget to add option value type handler import into
+ grc/python/flow_graph.tmpl for each new type. -->
<!-- not supported yet in tmpl
<option>
<name>Boolean</name>
diff --git a/grc/core/generator/flow_graph.tmpl
b/grc/core/generator/flow_graph.tmpl
index 07c4169..38b113f 100644
--- a/grc/core/generator/flow_graph.tmpl
+++ b/grc/core/generator/flow_graph.tmpl
@@ -336,18 +336,18 @@ $short_id#slurp
def argument_parser():
- #set $desc_args = 'usage="%prog: [options]", option_class=eng_option'
+ #set $arg_parser_args = ''
#if $flow_graph.get_option('description')
- #set $desc_args += ', description=description'
+ #set $arg_parser_args = 'description=description'
description = $repr($flow_graph.get_option('description'))
#end if
- parser = OptionParser($desc_args)
+ parser = ArgumentParser($arg_parser_args)
#for $param in $parameters
#set $type = $param.get_param('type').get_value()
#if $type
#silent $params_eq_list.append('%s=options.%s'%($param.get_id(),
$param.get_id()))
- parser.add_option(
- "$make_short_id($param)", "--$param.get_id().replace('_', '-')",
dest="$param.get_id()", type="$type", default=$make_default($type, $param),
+ parser.add_argument(
+ "$make_short_id($param)", "--$param.get_id().replace('_', '-')",
dest="$param.get_id()", type=$type, default=$make_default($type, $param),
help="Set $($param.get_param('label').get_evaluated() or
$param.get_id()) [default=%default]")
#end if
#end for
@@ -358,7 +358,7 @@ def argument_parser():
def main(top_block_cls=$(class_name), options=None):
#if $parameters
if options is None:
- options, _ = argument_parser().parse_args()
+ options = argument_parser().parse_args()
#end if
#if $flow_graph.get_option('realtime_scheduling')
if gr.enable_realtime_scheduling() != gr.RT_OK:
- [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 <=
- [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, 2016/05/11