From 1a78954f9362642b56c557413ee34376c35a8603 Mon Sep 17 00:00:00 2001 From: Moritz Venn Date: Wed, 23 Sep 2009 16:07:02 +0000 Subject: [PATCH] cleanup --- webinterface/src/WebChilds/FileStreamer.py | 2 +- webinterface/src/WebChilds/IPKG.py | 2 +- webinterface/src/WebChilds/PlayService.py | 6 +-- webinterface/src/WebComponents/Sources/EPG.py | 4 +- webinterface/src/WebComponents/Sources/Timer.py | 56 ++++++++++------------ .../src/WebComponents/Sources/WAPfunctions.py | 8 ++-- 6 files changed, 37 insertions(+), 41 deletions(-) diff --git a/webinterface/src/WebChilds/FileStreamer.py b/webinterface/src/WebChilds/FileStreamer.py index cf4d976..c2d42e6 100644 --- a/webinterface/src/WebChilds/FileStreamer.py +++ b/webinterface/src/WebChilds/FileStreamer.py @@ -12,7 +12,7 @@ class FileStreamer(resource.Resource): else: dir = '' - if request.args.has_key("file"): + if 'file' in request: filename = unquote_plus(request.args["file"][0]) path = "%s%s" %(dir, filename) diff --git a/webinterface/src/WebChilds/IPKG.py b/webinterface/src/WebChilds/IPKG.py index 88d0c54..a9fbce0 100755 --- a/webinterface/src/WebChilds/IPKG.py +++ b/webinterface/src/WebChilds/IPKG.py @@ -84,7 +84,7 @@ class IPKGResource(resource.Resource): return server.NOT_DONE_YET def getArg(self, key): - if self.args.has_key(key): + if key in self.args: return self.args[key][0] else: return None diff --git a/webinterface/src/WebChilds/PlayService.py b/webinterface/src/WebChilds/PlayService.py index bf6c446..5df4554 100755 --- a/webinterface/src/WebChilds/PlayService.py +++ b/webinterface/src/WebChilds/PlayService.py @@ -9,11 +9,11 @@ class ServiceplayerResource(resource.Resource): self.oldservice = None def render(self, request): - if request.args.has_key("file"): + if 'file' in request.args: output = self.playFile(request.args['file'][0]) - elif request.args.has_key("url"): + elif 'url' in request.args: output = self.playURL(request.args['url'][0]) - elif request.args.has_key("stop"): + elif 'stop' in request.args: output = self.stopServicePlay() else: output = True, "unknown command" diff --git a/webinterface/src/WebComponents/Sources/EPG.py b/webinterface/src/WebComponents/Sources/EPG.py index 6984628..da8ff52 100644 --- a/webinterface/src/WebComponents/Sources/EPG.py +++ b/webinterface/src/WebComponents/Sources/EPG.py @@ -107,11 +107,11 @@ class EPG(Source): def getEPGofBouquet(self, param): print "[WebComponents.EPG] getting EPG for Bouquet", param - if not param.has_key('bRef'): + if 'bRef' not in param: return () time = -1 - if param.has_key('time'): + if 'time' in param: if param['time'] is not None: time = int(float(param['time'])) if time < 0: diff --git a/webinterface/src/WebComponents/Sources/Timer.py b/webinterface/src/WebComponents/Sources/Timer.py index a8f3dad..4ff7aa2 100644 --- a/webinterface/src/WebComponents/Sources/Timer.py +++ b/webinterface/src/WebComponents/Sources/Timer.py @@ -71,17 +71,17 @@ class Timer(Source): def delTimer(self, param): print "[WebComponents.Timer] delTimer" - if param.has_key('sRef'): + if 'sRef' in param: service_ref = ServiceReference(param['sRef']) else: return ( False, "Missing Parameter: sRef" ) - if param.has_key('begin'): + if 'begin' in param: begin = int(float(param['begin'])) else: return ( False, "Missing Parameter: begin" ) - if param.has_key('end'): + if 'end' in param: end = int(float(param['end'])) else: return ( False, "Missing Parameter: end" ) @@ -138,7 +138,7 @@ class Timer(Source): repeated = int(param.get('repeated') or 0) if repeated == 0: for element in ("mo", "tu", "we", "th", "fr", "sa", "su", "ms", "mf"): - if param.has_key(element): + if element in param: number = param[element] or 0 del param[element] repeated = repeated + int(number) @@ -216,18 +216,17 @@ class Timer(Source): #for others (the serviceReference or the Begin/End time of the timer #we have to quit if they are not set/have illegal values - if param.has_key('sRef'): - service_ref = ServiceReference(param['sRef']) - else: + if 'sRef' not in param: return ( False, "Missing Parameter: sRef" ) + service_ref = ServiceReference(param['sRef']) repeated = int(param.get('repeated') or 0) - if not param.has_key('begin'): + if 'begin' not in param: return ( False, "Missing Parameter: begin" ) begin = int(float(param['begin'])) - if not param.has_key('end'): + if 'end' not in param: return ( False, "Missing Parameter: end" ) end = int(float(param['end'])) @@ -239,18 +238,16 @@ class Timer(Source): elif repeated == 0: return ( False, "Illegal Parameter value for Parameter begin : '%s'" % begin ) - if param.has_key('name'): - name = param['name'] - else: + if 'name' not in param: return ( False, "Missing Parameter: name" ) + name = param['name'] - if param.has_key('description'): - description = param['description'].replace("\n", " ") - else: + if 'description' not in param: return ( False, "Missing Parameter: description" ) + description = param['description'].replace("\n", " ") disabled = False #Default to: Enabled - if param.has_key('disabled'): + if 'disabled' in param: if param['disabled'] == "1": disabled = True else: @@ -258,45 +255,43 @@ class Timer(Source): pass justplay = False #Default to: Record - if param.has_key('justplay'): + if 'justplay' in param: if param['justplay'] == "1": justplay = True afterEvent = 3 #Default to Afterevent: Auto - if param.has_key('afterevent'): + if 'afterevent' in param: if (param['afterevent'] == "0") or (param['afterevent'] == "1") or (param['afterevent'] == "2"): afterEvent = int(param['afterevent']) dirname = config.movielist.last_timer_videodir.value - if param.has_key('dirname') and param['dirname']: + if 'dirname' in param and param['dirname']: dirname = param['dirname'] tags = [] - if param.has_key('tags') and param['tags']: + if 'tags' in param and param['tags']: tags = unescape(param['tags']).split(' ') delold = 0 - if param.has_key('deleteOldOnSave'): + if 'deleteOldOnSave' in param: delold = int(param['deleteOldOnSave']) #Try to edit an existing Timer if delold: - if param.has_key('channelOld') and param['channelOld'] != '': + if 'channelOld' in param and param['channelOld']: channelOld = ServiceReference(param['channelOld']) else: return ( False, "Missing Parameter: channelOld" ) # We do need all of the following Parameters, too, for being able of finding the Timer. # Therefore so we can neither use default values in this part nor can we # continue if a parameter is missing - if param.has_key('beginOld'): - beginOld = int(param['beginOld']) - else: + if 'beginOld' not in param: return ( False, "Missing Parameter: beginOld" ) + beginOld = int(param['beginOld']) - if param.has_key('endOld'): - endOld = int(param['endOld']) - else: + if 'endOld' not in param: return ( False, "Missing Parameter: endOld" ) + endOld = int(param['endOld']) #let's try to find the timer try: @@ -356,10 +351,11 @@ class Timer(Source): justplay = True location = config.movielist.last_timer_videodir.value - if param.has_key('dirname') and param['dirname']: + if 'dirname' in param and param['dirname']: location = param['dirname'] + tags = [] - if param.has_key('tags') and param['tags']: + if 'tags' in param and param['tags']: tags = unescape(param['tags']).split(' ') epgcache = eEPGCache.getInstance() diff --git a/webinterface/src/WebComponents/Sources/WAPfunctions.py b/webinterface/src/WebComponents/Sources/WAPfunctions.py index dec49e2..9bf00e4 100644 --- a/webinterface/src/WebComponents/Sources/WAPfunctions.py +++ b/webinterface/src/WebComponents/Sources/WAPfunctions.py @@ -60,13 +60,13 @@ class WAPfunctions(Source): timeNow = time() timePlusTwo = timeNow + 7200 - if param.has_key('begin'): + if 'begin' in param: begin = param['begin'] or 0 begin = int(begin) del param['begin'] if begin > 0: timeNow = begin - if param.has_key('end'): + if 'end' in param: end = param['end'] or 0 end = int(end) del param['end'] @@ -301,14 +301,14 @@ class WAPfunctions(Source): def fillOptionList(self, param): print "fillOptionList", param - if param.has_key("justplay"): + if "justplay" in param: number = param["justplay"] or 0 number = int(number) return ( ("Record", 0, number == 0 and "selected" or ""), ("Zap", 1, number == 1 and "selected" or "") ) - elif param.has_key("afterevent"): + elif "afterevent" in param: number = param["afterevent"] or 0 number = int(number) return ( -- 2.7.4