diff options
author | Jiří Pinkava <j-pi@seznam.cz> | 2016-06-28 13:14:38 +0200 |
---|---|---|
committer | Jiří Pinkava <j-pi@seznam.cz> | 2016-06-28 13:14:54 +0200 |
commit | 2013f22b4e2203f88f482ff545aaafee35c72494 (patch) | |
tree | 29d8dce5ca93452c17c21bacb6a939b55df3d492 | |
parent | 3b2566122d89a1c23460f8d1f3e558b872666612 (diff) |
simplify application of staticmethod in .py
-rw-r--r-- | gr-digital/examples/narrowband/receive_path.py | 8 | ||||
-rw-r--r-- | gr-digital/examples/narrowband/transmit_path.py | 4 | ||||
-rw-r--r-- | gr-digital/examples/narrowband/uhd_interface.py | 10 | ||||
-rw-r--r-- | gr-digital/examples/ofdm/receive_path.py | 8 | ||||
-rw-r--r-- | gr-digital/examples/ofdm/transmit_path.py | 6 | ||||
-rw-r--r-- | gr-digital/examples/ofdm/uhd_interface.py | 10 | ||||
-rw-r--r-- | gr-digital/python/digital/cpm.py | 6 | ||||
-rw-r--r-- | gr-digital/python/digital/generic_mod_demod.py | 6 | ||||
-rw-r--r-- | gr-digital/python/digital/gfsk.py | 17 | ||||
-rw-r--r-- | gr-digital/python/digital/gmsk.py | 17 | ||||
-rw-r--r-- | gr-digital/python/digital/ofdm.py | 6 | ||||
-rw-r--r-- | gr-uhd/apps/hf_radio/input.py | 2 |
12 files changed, 33 insertions, 67 deletions
diff --git a/gr-digital/examples/narrowband/receive_path.py b/gr-digital/examples/narrowband/receive_path.py index dc155e1d12..8bbfe92770 100644 --- a/gr-digital/examples/narrowband/receive_path.py +++ b/gr-digital/examples/narrowband/receive_path.py @@ -124,8 +124,8 @@ class receive_path(gr.hier_block2): threshold_in_db: set detection threshold (float (dB)) """ self.probe.set_threshold(threshold_in_db) - - + + @staticmethod def add_options(normal, expert): """ Adds receiver-specific options to the Options Parser @@ -141,10 +141,6 @@ class receive_path(gr.hier_block2): expert.add_option("", "--chbw-factor", type="float", default=1.0, help="Channel bandwidth = chbw_factor x signal bandwidth [defaut=%default]") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - def _print_verbage(self): """ Prints information about the receive path diff --git a/gr-digital/examples/narrowband/transmit_path.py b/gr-digital/examples/narrowband/transmit_path.py index 43a96050e9..70b4044e52 100644 --- a/gr-digital/examples/narrowband/transmit_path.py +++ b/gr-digital/examples/narrowband/transmit_path.py @@ -94,6 +94,7 @@ class transmit_path(gr.hier_block2): def differential(self): return self.modulator._differential + @staticmethod def add_options(normal, expert): """ Adds transmitter-specific options to the Options Parser @@ -115,9 +116,6 @@ class transmit_path(gr.hier_block2): default=False, help="Log all parts of flow graph to file (CAUTION: lots of data)") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - def _print_verbage(self): """ Prints information about the transmit path diff --git a/gr-digital/examples/narrowband/uhd_interface.py b/gr-digital/examples/narrowband/uhd_interface.py index 474e96f486..e7c7fe3af0 100644 --- a/gr-digital/examples/narrowband/uhd_interface.py +++ b/gr-digital/examples/narrowband/uhd_interface.py @@ -145,7 +145,8 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): if(verbose): self._print_verbage() - + + @staticmethod def add_options(parser): add_freq_option(parser) parser.add_option("-a", "--args", type="string", default="", @@ -165,9 +166,6 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): help="select clock source (e.g. 'external') [default=%default]") parser.add_option("-v", "--verbose", action="store_true", default=False) - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - def _print_verbage(self): """ Prints information about the UHD transmitter @@ -203,6 +201,7 @@ class uhd_receiver(uhd_interface, gr.hier_block2): if(verbose): self._print_verbage() + @staticmethod def add_options(parser): add_freq_option(parser) parser.add_option("-a", "--args", type="string", default="", @@ -223,9 +222,6 @@ class uhd_receiver(uhd_interface, gr.hier_block2): if not parser.has_option("--verbose"): parser.add_option("-v", "--verbose", action="store_true", default=False) - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - def _print_verbage(self): """ Prints information about the UHD transmitter diff --git a/gr-digital/examples/ofdm/receive_path.py b/gr-digital/examples/ofdm/receive_path.py index 2a6813f8f9..0cb4479a2e 100644 --- a/gr-digital/examples/ofdm/receive_path.py +++ b/gr-digital/examples/ofdm/receive_path.py @@ -82,8 +82,8 @@ class receive_path(gr.hier_block2): threshold_in_db: set detection threshold (float (dB)) """ self.probe.set_threshold(threshold_in_db) - - + + @staticmethod def add_options(normal, expert): """ Adds receiver-specific options to the Options Parser @@ -95,10 +95,6 @@ class receive_path(gr.hier_block2): expert.add_option("", "--log", action="store_true", default=False, help="Log all parts of flow graph to files (CAUTION: lots of data)") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - def _print_verbage(self): """ Prints information about the receive path diff --git a/gr-digital/examples/ofdm/transmit_path.py b/gr-digital/examples/ofdm/transmit_path.py index aa146cea96..98a81f3c1a 100644 --- a/gr-digital/examples/ofdm/transmit_path.py +++ b/gr-digital/examples/ofdm/transmit_path.py @@ -75,7 +75,8 @@ class transmit_path(gr.hier_block2): Calls the transmitter method to send a packet """ return self.ofdm_tx.send_pkt(payload, eof) - + + @staticmethod def add_options(normal, expert): """ Adds transmitter-specific options to the Options Parser @@ -92,9 +93,6 @@ class transmit_path(gr.hier_block2): default=False, help="Log all parts of flow graph to file (CAUTION: lots of data)") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - def _print_verbage(self): """ Prints information about the transmit path diff --git a/gr-digital/examples/ofdm/uhd_interface.py b/gr-digital/examples/ofdm/uhd_interface.py index 5b4d707b07..ac34d956ae 100644 --- a/gr-digital/examples/ofdm/uhd_interface.py +++ b/gr-digital/examples/ofdm/uhd_interface.py @@ -126,7 +126,8 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): if(verbose): self._print_verbage() - + + @staticmethod def add_options(parser): add_freq_option(parser) parser.add_option("-a", "--args", type="string", default="", @@ -146,9 +147,6 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): help="select clock source (e.g. 'external') [default=%default]") parser.add_option("-v", "--verbose", action="store_true", default=False) - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - def _print_verbage(self): """ Prints information about the UHD transmitter @@ -186,6 +184,7 @@ class uhd_receiver(uhd_interface, gr.hier_block2): if(verbose): self._print_verbage() + @staticmethod def add_options(parser): add_freq_option(parser) parser.add_option("-a", "--args", type="string", default="", @@ -206,9 +205,6 @@ class uhd_receiver(uhd_interface, gr.hier_block2): if not parser.has_option("--verbose"): parser.add_option("-v", "--verbose", action="store_true", default=False) - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - def _print_verbage(self): """ Prints information about the UHD transmitter diff --git a/gr-digital/python/digital/cpm.py b/gr-digital/python/digital/cpm.py index b27fb098f5..322c3f0bfc 100644 --- a/gr-digital/python/digital/cpm.py +++ b/gr-digital/python/digital/cpm.py @@ -204,23 +204,21 @@ class cpm_mod(gr.hier_block2): self.connect(self.fmmod, blocks.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) - + @staticmethod def add_options(parser): """ Adds CPM modulation-specific options to the standard parser """ parser.add_option("", "--bt", type="float", default=_def_bt, help="set bandwidth-time product [default=%default] (GMSK)") - add_options=staticmethod(add_options) - + @staticmethod def extract_kwargs_from_options(options): """ Given command line options, create dictionary suitable for passing to __init__ """ return modulation_utils.extract_kwargs_from_options(cpm_mod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) diff --git a/gr-digital/python/digital/generic_mod_demod.py b/gr-digital/python/digital/generic_mod_demod.py index f34994fa7b..1b8e1149c9 100644 --- a/gr-digital/python/digital/generic_mod_demod.py +++ b/gr-digital/python/digital/generic_mod_demod.py @@ -175,12 +175,12 @@ class generic_mod(gr.hier_block2): def bits_per_symbol(self): # static method that's also callable on an instance return self._constellation.bits_per_symbol() + @staticmethod def add_options(parser): """ Adds generic modulation options to the standard parser """ add_common_options(parser) - add_options=staticmethod(add_options) def extract_kwargs_from_options(cls, options): """ @@ -324,7 +324,7 @@ class generic_demod(gr.hier_block2): def samples_per_symbol(self): return self._samples_per_symbol - def bits_per_symbol(self): # staticmethod that's also callable on an instance + def bits_per_symbol(self): return self._constellation.bits_per_symbol() def _print_verbage(self): @@ -372,6 +372,7 @@ class generic_demod(gr.hier_block2): self.connect(self.unpack, blocks.file_sink(gr.sizeof_char, "rx_unpack.8b")) + @staticmethod def add_options(parser): """ Adds generic demodulation options to the standard parser @@ -385,7 +386,6 @@ class generic_demod(gr.hier_block2): help="set phase tracking loop lock-in bandwidth [default=%default]") parser.add_option("", "--timing-bw", type="float", default=_def_timing_bw, help="set timing symbol sync loop gain lock-in bandwidth [default=%default]") - add_options=staticmethod(add_options) def extract_kwargs_from_options(cls, options): """ diff --git a/gr-digital/python/digital/gfsk.py b/gr-digital/python/digital/gfsk.py index 6ba007ca0f..3569ffe6cf 100644 --- a/gr-digital/python/digital/gfsk.py +++ b/gr-digital/python/digital/gfsk.py @@ -133,10 +133,9 @@ class gfsk_mod(gr.hier_block2): def samples_per_symbol(self): return self._samples_per_symbol + @staticmethod def bits_per_symbol(self=None): # staticmethod that's also callable on an instance return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. - def _print_verbage(self): print "bits per symbol = %d" % self.bits_per_symbol() @@ -152,24 +151,21 @@ class gfsk_mod(gr.hier_block2): self.connect(self.fmmod, blocks.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) - + @staticmethod def add_options(parser): """ Adds GFSK modulation-specific options to the standard parser """ parser.add_option("", "--bt", type="float", default=_def_bt, help="set bandwidth-time product [default=%default] (GFSK)") - add_options=staticmethod(add_options) - + @staticmethod def extract_kwargs_from_options(options): """ Given command line options, create dictionary suitable for passing to __init__ """ return modulation_utils.extract_kwargs_from_options(gfsk_mod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - # ///////////////////////////////////////////////////////////////////////////// @@ -255,10 +251,9 @@ class gfsk_demod(gr.hier_block2): def samples_per_symbol(self): return self._samples_per_symbol + @staticmethod def bits_per_symbol(self=None): # staticmethod that's also callable on an instance return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. - def _print_verbage(self): print "bits per symbol = %d" % self.bits_per_symbol() @@ -278,6 +273,7 @@ class gfsk_demod(gr.hier_block2): self.connect(self.slicer, blocks.file_sink(gr.sizeof_char, "slicer.dat")) + @staticmethod def add_options(parser): """ Adds GFSK demodulation-specific options to the standard parser @@ -290,15 +286,14 @@ class gfsk_demod(gr.hier_block2): help="M&M clock recovery omega relative limit [default=%default] (GFSK/PSK)") parser.add_option("", "--freq-error", type="float", default=_def_freq_error, help="M&M clock recovery frequency error [default=%default] (GFSK)") - add_options=staticmethod(add_options) + @staticmethod def extract_kwargs_from_options(options): """ Given command line options, create dictionary suitable for passing to __init__ """ return modulation_utils.extract_kwargs_from_options(gfsk_demod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) # diff --git a/gr-digital/python/digital/gmsk.py b/gr-digital/python/digital/gmsk.py index 284f85f333..e7a92a95db 100644 --- a/gr-digital/python/digital/gmsk.py +++ b/gr-digital/python/digital/gmsk.py @@ -123,10 +123,9 @@ class gmsk_mod(gr.hier_block2): def samples_per_symbol(self): return self._samples_per_symbol + @staticmethod def bits_per_symbol(self=None): # staticmethod that's also callable on an instance return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. - def _print_verbage(self): print "bits per symbol = %d" % self.bits_per_symbol() @@ -142,24 +141,21 @@ class gmsk_mod(gr.hier_block2): self.connect(self.fmmod, blocks.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) - + @staticmethod def add_options(parser): """ Adds GMSK modulation-specific options to the standard parser """ parser.add_option("", "--bt", type="float", default=_def_bt, help="set bandwidth-time product [default=%default] (GMSK)") - add_options=staticmethod(add_options) - + @staticmethod def extract_kwargs_from_options(options): """ Given command line options, create dictionary suitable for passing to __init__ """ return modulation_utils.extract_kwargs_from_options(gmsk_mod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - # ///////////////////////////////////////////////////////////////////////////// @@ -239,10 +235,9 @@ class gmsk_demod(gr.hier_block2): def samples_per_symbol(self): return self._samples_per_symbol + @staticmethod def bits_per_symbol(self=None): # staticmethod that's also callable on an instance return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. - def _print_verbage(self): print "bits per symbol = %d" % self.bits_per_symbol() @@ -262,6 +257,7 @@ class gmsk_demod(gr.hier_block2): self.connect(self.slicer, blocks.file_sink(gr.sizeof_char, "slicer.dat")) + @staticmethod def add_options(parser): """ Adds GMSK demodulation-specific options to the standard parser @@ -274,15 +270,14 @@ class gmsk_demod(gr.hier_block2): help="M&M clock recovery omega relative limit [default=%default] (GMSK/PSK)") parser.add_option("", "--freq-error", type="float", default=_def_freq_error, help="M&M clock recovery frequency error [default=%default] (GMSK)") - add_options=staticmethod(add_options) + @staticmethod def extract_kwargs_from_options(options): """ Given command line options, create dictionary suitable for passing to __init__ """ return modulation_utils.extract_kwargs_from_options(gmsk_demod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) # diff --git a/gr-digital/python/digital/ofdm.py b/gr-digital/python/digital/ofdm.py index fdb23703f9..563b70ad00 100644 --- a/gr-digital/python/digital/ofdm.py +++ b/gr-digital/python/digital/ofdm.py @@ -146,6 +146,7 @@ class ofdm_mod(gr.hier_block2): msg = gr.message_from_string(pkt) self._pkt_input.msgq().insert_tail(msg) + @staticmethod def add_options(normal, expert): """ Adds OFDM-specific options to the Options Parser @@ -158,8 +159,6 @@ class ofdm_mod(gr.hier_block2): help="set the number of occupied FFT bins [default=%default]") expert.add_option("", "--cp-length", type="intx", default=128, help="set the number of bits in the cyclic prefix [default=%default]") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) def _print_verbage(self): """ @@ -267,6 +266,7 @@ class ofdm_demod(gr.hier_block2): self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback) + @staticmethod def add_options(normal, expert): """ Adds OFDM-specific options to the Options Parser @@ -281,8 +281,6 @@ class ofdm_demod(gr.hier_block2): help="set the number of bits in the cyclic prefix [default=%default]") expert.add_option("", "--snr", type="float", default=30.0, help="SNR estimate [default=%default]") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) def _print_verbage(self): """ diff --git a/gr-uhd/apps/hf_radio/input.py b/gr-uhd/apps/hf_radio/input.py index fd2ac47a5c..49df347e8b 100644 --- a/gr-uhd/apps/hf_radio/input.py +++ b/gr-uhd/apps/hf_radio/input.py @@ -65,6 +65,7 @@ class uhd_input(gr.hier_block2): self.gain = gain self.src.set_gain(gain, 0) + @staticmethod def add_options(parser): parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", @@ -75,4 +76,3 @@ class uhd_input(gr.hier_block2): help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") - add_options = staticmethod(add_options) |