From 647889e65bc8aabd907bc327e62c6209a947ae1b Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 12 Dec 2008 12:58:25 +0100 Subject: cleanup --- lib/python/Components/ServiceScan.py | 86 ++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 47 deletions(-) (limited to 'lib/python/Components/ServiceScan.py') diff --git a/lib/python/Components/ServiceScan.py b/lib/python/Components/ServiceScan.py index 5a7b3dea..5d624264 100644 --- a/lib/python/Components/ServiceScan.py +++ b/lib/python/Components/ServiceScan.py @@ -36,54 +36,46 @@ class ServiceScan: tp_text = "" if transponder: tp_type = transponder.getSystem() - if not tp_type[0]: - tp_type = tp_type[1] - if tp_type == iDVBFrontend.feSatellite: - network = _("Satellite") - tp = transponder.getDVBS() - if not tp[0]: - tp = tp[1] - orb_pos = tp.orbital_position - try: - sat_name = str(nimmgr.getSatDescription(orb_pos)) - except KeyError: - sat_name = "" - if orb_pos > 1800: # west - orb_pos = 3600 - orb_pos - h = _("W") - else: - h = _("E") - if sat_name.find("%d.%d" % (orb_pos/10, orb_pos%10)) != -1: - network = sat_name - else: - network = ("%s %d.%d %s") % (sat_name, orb_pos / 10, orb_pos % 10, h) - tp_text = ("%s %s %d%c / %d / %s") %( { 0 : "DVB-S", 1 : "DVB-S2" }[tp.system], - { 0 : "Auto", 1 : "QPSK", 2 : "M8PSK", 3 : "QAM16" }[tp.modulation], - tp.frequency/1000, - { 0 : 'H', 1 : 'V', 2 : 'L', 3 : 'R' }[tp.polarisation], - tp.symbol_rate/1000, - { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", - 5 : "7/8", 6 : "8/9", 7 : "3/5", 8 : "4/5", 9 : "9/10", - 15 : "NONE" }[tp.fec] ) - elif tp_type == iDVBFrontend.feCable: - network = _("Cable") - tp = transponder.getDVBC() - if not tp[0]: - tp = tp[1] - tp_text = ("DVB-C %s %d / %d / %s") %( { 0 : "AUTO", 1 : "QAM16", 2 : "QAM32", 3 : "QAM64", 4 : "QAM128", 5 : "QAM256" }[tp.modulation], - tp.frequency, - tp.symbol_rate/1000, - { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", 5 : "7/8", 6 : "8/9", 15 : "NONE" }[tp.fec_inner] ) - elif tp_type == iDVBFrontend.feTerrestrial: - network = _("Terrestrial") - tp = transponder.getDVBT() - if not tp[0]: - tp = tp[1] - tp_text = ("DVB-T %s %d %s") %( { 0 : "QPSK", 1 : "QAM16", 2 : "QAM64", 3 : "AUTO"}[tp.modulation], - tp.frequency, - { 0 : "Bw 8MHz", 1 : "Bw 7MHz", 2 : "Bw 6MHz", 3 : "Bw Auto" }[tp.bandwidth]) + if tp_type == iDVBFrontend.feSatellite: + network = _("Satellite") + tp = transponder.getDVBS() + orb_pos = tp.orbital_position + try: + sat_name = str(nimmgr.getSatDescription(orb_pos)) + except KeyError: + sat_name = "" + if orb_pos > 1800: # west + orb_pos = 3600 - orb_pos + h = _("W") else: - print "unknown transponder type in scanStatusChanged" + h = _("E") + if sat_name.find("%d.%d" % (orb_pos/10, orb_pos%10)) != -1: + network = sat_name + else: + network = ("%s %d.%d %s") % (sat_name, orb_pos / 10, orb_pos % 10, h) + tp_text = ("%s %s %d%c / %d / %s") %( { 0 : "DVB-S", 1 : "DVB-S2" }[tp.system], + { 0 : "Auto", 1 : "QPSK", 2 : "M8PSK", 3 : "QAM16" }[tp.modulation], + tp.frequency/1000, + { 0 : 'H', 1 : 'V', 2 : 'L', 3 : 'R' }[tp.polarisation], + tp.symbol_rate/1000, + { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", + 5 : "7/8", 6 : "8/9", 7 : "3/5", 8 : "4/5", 9 : "9/10", + 15 : "NONE" }[tp.fec] ) + elif tp_type == iDVBFrontend.feCable: + network = _("Cable") + tp = transponder.getDVBC() + tp_text = ("DVB-C %s %d / %d / %s") %( { 0 : "AUTO", 1 : "QAM16", 2 : "QAM32", 3 : "QAM64", 4 : "QAM128", 5 : "QAM256" }[tp.modulation], + tp.frequency, + tp.symbol_rate/1000, + { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", 5 : "7/8", 6 : "8/9", 15 : "NONE" }[tp.fec_inner] ) + elif tp_type == iDVBFrontend.feTerrestrial: + network = _("Terrestrial") + tp = transponder.getDVBT() + tp_text = ("DVB-T %s %d %s") %( { 0 : "QPSK", 1 : "QAM16", 2 : "QAM64", 3 : "AUTO"}[tp.modulation], + tp.frequency, + { 0 : "Bw 8MHz", 1 : "Bw 7MHz", 2 : "Bw 6MHz", 3 : "Bw Auto" }[tp.bandwidth]) + else: + print "unknown transponder type in scanStatusChanged" self.network.setText(network) self.transponder.setText(tp_text) -- cgit v1.2.3 From ac91892f80fccfc09347cd1314b7e0ba88842be7 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 30 Jan 2009 17:07:49 +0100 Subject: use .get instead of operator [] --- lib/python/Components/ServiceScan.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/python/Components/ServiceScan.py') diff --git a/lib/python/Components/ServiceScan.py b/lib/python/Components/ServiceScan.py index 5d624264..f2b0c053 100644 --- a/lib/python/Components/ServiceScan.py +++ b/lib/python/Components/ServiceScan.py @@ -53,27 +53,27 @@ class ServiceScan: network = sat_name else: network = ("%s %d.%d %s") % (sat_name, orb_pos / 10, orb_pos % 10, h) - tp_text = ("%s %s %d%c / %d / %s") %( { 0 : "DVB-S", 1 : "DVB-S2" }[tp.system], - { 0 : "Auto", 1 : "QPSK", 2 : "M8PSK", 3 : "QAM16" }[tp.modulation], + tp_text = ("%s %s %d%c / %d / %s") %( { 0 : "DVB-S", 1 : "DVB-S2" }.get(tp.system, 0), + { 0 : "Auto", 1 : "QPSK", 2 : "8PSK", 3 : "QAM16" }.get(tp.modulation, 0), tp.frequency/1000, - { 0 : 'H', 1 : 'V', 2 : 'L', 3 : 'R' }[tp.polarisation], + { 0 : 'H', 1 : 'V', 2 : 'L', 3 : 'R' }.get(tp.polarisation, 0), tp.symbol_rate/1000, { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", 5 : "7/8", 6 : "8/9", 7 : "3/5", 8 : "4/5", 9 : "9/10", - 15 : "NONE" }[tp.fec] ) + 15 : "NONE" }.get(tp.fec, 0)) elif tp_type == iDVBFrontend.feCable: network = _("Cable") tp = transponder.getDVBC() - tp_text = ("DVB-C %s %d / %d / %s") %( { 0 : "AUTO", 1 : "QAM16", 2 : "QAM32", 3 : "QAM64", 4 : "QAM128", 5 : "QAM256" }[tp.modulation], + tp_text = ("DVB-C %s %d / %d / %s") %( { 0 : "AUTO", 1 : "QAM16", 2 : "QAM32", 3 : "QAM64", 4 : "QAM128", 5 : "QAM256" }.get(tp.modulation, 0), tp.frequency, tp.symbol_rate/1000, - { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", 5 : "7/8", 6 : "8/9", 15 : "NONE" }[tp.fec_inner] ) + { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", 5 : "7/8", 6 : "8/9", 15 : "NONE" }.get(tp.fec_inner, 0)) elif tp_type == iDVBFrontend.feTerrestrial: network = _("Terrestrial") tp = transponder.getDVBT() - tp_text = ("DVB-T %s %d %s") %( { 0 : "QPSK", 1 : "QAM16", 2 : "QAM64", 3 : "AUTO"}[tp.modulation], + tp_text = ("DVB-T %s %d %s") %( { 0 : "QPSK", 1 : "QAM16", 2 : "QAM64", 3 : "AUTO" }.get(tp.modulation, 3), tp.frequency, - { 0 : "Bw 8MHz", 1 : "Bw 7MHz", 2 : "Bw 6MHz", 3 : "Bw Auto" }[tp.bandwidth]) + { 0 : "Bw 8MHz", 1 : "Bw 7MHz", 2 : "Bw 6MHz", 3 : "Bw Auto" }.get(tp.bandwidth, 3)) else: print "unknown transponder type in scanStatusChanged" self.network.setText(network) -- cgit v1.2.3 From 4b811a968884ce645d71cf22d538bd646acdc677 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 30 Jan 2009 19:47:50 +0100 Subject: use enum values from frontendparams.h --- lib/python/Components/ServiceScan.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'lib/python/Components/ServiceScan.py') diff --git a/lib/python/Components/ServiceScan.py b/lib/python/Components/ServiceScan.py index f2b0c053..78cd758e 100644 --- a/lib/python/Components/ServiceScan.py +++ b/lib/python/Components/ServiceScan.py @@ -53,27 +53,39 @@ class ServiceScan: network = sat_name else: network = ("%s %d.%d %s") % (sat_name, orb_pos / 10, orb_pos % 10, h) - tp_text = ("%s %s %d%c / %d / %s") %( { 0 : "DVB-S", 1 : "DVB-S2" }.get(tp.system, 0), - { 0 : "Auto", 1 : "QPSK", 2 : "8PSK", 3 : "QAM16" }.get(tp.modulation, 0), + tp_text = ("%s %s %d%c / %d / %s") %( { tp.System_DVB_S : "DVB-S", + tp.System_DVB_S2 : "DVB-S2" }.get(tp.system, tp.System_DVB_S), + { tp.Modulation_Auto : "Auto", tp.Modulation_QPSK : "QPSK", + tp.Modulation_8PSK : "8PSK", tp.Modulation_QAM16 : "QAM16" }.get(tp.modulation, tp.Modulation_QPSK), tp.frequency/1000, - { 0 : 'H', 1 : 'V', 2 : 'L', 3 : 'R' }.get(tp.polarisation, 0), + { tp.Polarisation_Horizontal : 'H', tp.Polarisation_Vertical : 'V', tp.Polarisation_CircularLeft : 'L', + tp.Polarisation_CircularRight : 'R' }.get(tp.polarisation, tp.Polarisation_Horizontal), tp.symbol_rate/1000, - { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", - 5 : "7/8", 6 : "8/9", 7 : "3/5", 8 : "4/5", 9 : "9/10", - 15 : "NONE" }.get(tp.fec, 0)) + { tp.FEC_Auto : "AUTO", tp.FEC_1_2 : "1/2", tp.FEC_2_3 : "2/3", + tp.FEC_3_4 : "3/4", tp.FEC_5_6 : "5/6", tp.FEC_7_8 : "7/8", + tp.FEC_8_9 : "8/9", tp.FEC_3_5 : "3/5", tp.FEC_4_5 : "4/5", + tp.FEC_9_10 : "9/10", tp.FEC_None : "NONE" }.get(tp.fec, tp.FEC_Auto)) elif tp_type == iDVBFrontend.feCable: network = _("Cable") tp = transponder.getDVBC() - tp_text = ("DVB-C %s %d / %d / %s") %( { 0 : "AUTO", 1 : "QAM16", 2 : "QAM32", 3 : "QAM64", 4 : "QAM128", 5 : "QAM256" }.get(tp.modulation, 0), + tp_text = ("DVB-C %s %d / %d / %s") %( { tp.Modulation_Auto : "AUTO", + tp.Modulation_QAM16 : "QAM16", tp.Modulation_QAM32 : "QAM32", + tp.Modulation_QAM64 : "QAM64", tp.Modulation_QAM128 : "QAM128", + tp.Modulation_QAM256 : "QAM256" }.get(tp.modulation, tp.Modulation_Auto), tp.frequency, tp.symbol_rate/1000, - { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", 5 : "7/8", 6 : "8/9", 15 : "NONE" }.get(tp.fec_inner, 0)) + { tp.FEC_Auto : "AUTO", tp.FEC_1_2 : "1/2", tp.FEC_2_3 : "2/3", + tp.FEC_3_4 : "3/4", tp.FEC_5_6 : "5/6", tp.FEC_7_8 : "7/8", + tp.FEC_8_9 : "8/9", tp.FEC_None : "NONE" }.get(tp.fec_inner, tp.FEC_Auto)) elif tp_type == iDVBFrontend.feTerrestrial: network = _("Terrestrial") tp = transponder.getDVBT() - tp_text = ("DVB-T %s %d %s") %( { 0 : "QPSK", 1 : "QAM16", 2 : "QAM64", 3 : "AUTO" }.get(tp.modulation, 3), + tp_text = ("DVB-T %s %d %s") %( { tp.Modulation_QPSK : "QPSK", + tp.Modulation_QAM16 : "QAM16", tp.Modulation_QAM64 : "QAM64", + tp.Modulation_Auto : "AUTO" }.get(tp.modulation, tp.Modulation_Auto), tp.frequency, - { 0 : "Bw 8MHz", 1 : "Bw 7MHz", 2 : "Bw 6MHz", 3 : "Bw Auto" }.get(tp.bandwidth, 3)) + { tp.Bandwidth_8MHz : "Bw 8MHz", tp.Bandwidth_7MHz : "Bw 7MHz", tp.Bandwidth_6MHz : "Bw 6MHz", + tp.Bandwidth_Auto : "Bw Auto" }.get(tp.bandwidth, tp.Bandwidth_Auto)) else: print "unknown transponder type in scanStatusChanged" self.network.setText(network) -- cgit v1.2.3