From 798c2f2c42f235238d5aeb52fb0819f32b127fee Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Thu, 29 Jan 2015 13:59:07 -0800 Subject: [PATCH] convert has_key to X in dictionary --- experiments/experiments.py | 22 +++++++++++----------- htsworkflow/auth.py | 2 +- htsworkflow/automation/spoolwatcher.py | 2 +- htsworkflow/frontend/analysis/main.py | 10 +++++----- htsworkflow/frontend/reports/reports.py | 6 +++--- htsworkflow/pipelines/bustard.py | 2 +- htsworkflow/pipelines/ipar.py | 2 +- htsworkflow/pipelines/summary.py | 2 +- htsworkflow/util/fctracker.py | 2 +- scripts/htsw-update-archive | 2 +- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/experiments/experiments.py b/experiments/experiments.py index b8f905e..8738224 100644 --- a/experiments/experiments.py +++ b/experiments/experiments.py @@ -148,22 +148,22 @@ def updStatus(request): user = request.user #Check access permission - if not (user.is_superuser and settings.ALLOWED_IPS.has_key(ClIP)): + if not (user.is_superuser and ClIP in settings.ALLOWED_IPS): return HttpResponse("%s access denied from %s." % (user, ClIP)) # ~~~~~~Parameters for the job ~~~~ - if request.REQUEST.has_key('fcid'): + if 'fcid' in request.REQUEST: fcid = request.REQUEST['fcid'] else: return HttpResponse('missing fcid') - if request.REQUEST.has_key('runf'): + if 'runf' in request.REQUEST: runfolder = request.REQUEST['runf'] else: return HttpResponse('missing runf') - if request.REQUEST.has_key('updst'): + if 'updst' in request.REQUEST: UpdatedStatus = request.REQUEST['updst'] else: return HttpResponse('missing status') @@ -179,7 +179,7 @@ def updStatus(request): #if there's a message update that too mytimestamp = timezone.now().__str__() mytimestamp = re.sub(pattern=":[^:]*$",repl="",string=mytimestamp) - if request.REQUEST.has_key('msg'): + if 'msg' in request.REQUEST: rec.run_note += ", "+request.REQUEST['msg']+" ("+mytimestamp+")" else : if UpdatedStatus == '1': @@ -201,7 +201,7 @@ def updStatus(request): def generateConfile(request,fcid): #granted = False #ClIP = request.META['REMOTE_ADDR'] - #if (settings.ALLOWED_IPS.has_key(ClIP)): granted = True + #if (ClIP in settings.ALLOWED_IPS): granted = True #if not granted: return HttpResponse("access denied.") @@ -228,7 +228,7 @@ def generateConfile(request,fcid): def getConfile(req): granted = False ClIP = req.META['REMOTE_ADDR'] - if (settings.ALLOWED_IPS.has_key(ClIP)): granted = True + if (ClIP in settings.ALLOWED_IPS): granted = True if not granted: return HttpResponse("access denied. IP: "+ClIP) @@ -236,9 +236,9 @@ def getConfile(req): cnfgfile = 'Nothing found' runfolder = 'unknown' request = req.REQUEST - if request.has_key('fcid'): + if 'fcid' in request: fcid = request['fcid'] - if request.has_key('runf'): + if 'runf' in request: runfolder = request['runf'] try: rec = DataRun.objects.get(run_folder=runfolder) #,flowcell_id=fcid) @@ -262,14 +262,14 @@ def getConfile(req): def getLaneLibs(req): granted = False ClIP = req.META['REMOTE_ADDR'] - if (settings.ALLOWED_IPS.has_key(ClIP)): granted = True + if (ClIP in settings.ALLOWED_IPS): granted = True if not granted: return HttpResponse("access denied.") request = req.REQUEST fcid = 'none' outputfile = '' - if request.has_key('fcid'): + if 'fcid' in request: fcid = request['fcid'] try: rec = FlowCell.objects.get(flowcell_id=fcid) diff --git a/htsworkflow/auth.py b/htsworkflow/auth.py index 5688cc9..1d781e1 100644 --- a/htsworkflow/auth.py +++ b/htsworkflow/auth.py @@ -8,7 +8,7 @@ apidata = {'apiid': u'0', 'apikey': settings.DEFAULT_API_KEY} def require_api_key(request): # make sure we have the api component - if not (request.REQUEST.has_key('apiid') or request.REQUEST.has_key('apikey')): + if not ('apiid' in request.REQUEST or 'apikey' in request.REQUEST): raise PermissionDenied # make sure the id and key are right diff --git a/htsworkflow/automation/spoolwatcher.py b/htsworkflow/automation/spoolwatcher.py index e226234..2888be0 100644 --- a/htsworkflow/automation/spoolwatcher.py +++ b/htsworkflow/automation/spoolwatcher.py @@ -72,7 +72,7 @@ class Handler(pyinotify.ProcessEvent): # if we've already seen an event in this directory (AKA runfolder) # keep track if its already hit the "completed" flag - if watch_path_events.has_key(target): + if target in watch_path_events: run_already_complete = watch_path_events[target].complete watch_path_events[target] = WatcherEvent(target) diff --git a/htsworkflow/frontend/analysis/main.py b/htsworkflow/frontend/analysis/main.py index ba2a739..71d711d 100644 --- a/htsworkflow/frontend/analysis/main.py +++ b/htsworkflow/frontend/analysis/main.py @@ -14,20 +14,20 @@ def updStatus(request): ClIP = request.META['REMOTE_ADDR'] #Check client access permission granted = False - if (settings.ALLOWED_ANALYS_IPS.has_key(ClIP)): granted = True + if (ClIP in settings.ALLOWED_ANALYS_IPS): granted = True if not granted: return HttpResponse("access denied.") output='' taskid=-1; # Check required param - if request.has_key('taskid'): taskid = request['taskid'] + if 'taskid' in request: taskid = request['taskid'] else: return HttpResponse('missing param task id') try: rec = Task.objects.get(id=taskid) mytimestamp = datetime.now().__str__() mytimestamp = re.sub(pattern=":[^:]*$",repl="",string=mytimestamp) - if request.has_key('msg'): + if 'msg' in request: rec.task_status += ", "+request['msg']+" ("+mytimestamp+")" else : rec.task_status = "Registered ("+mytimestamp+")" @@ -43,13 +43,13 @@ def getProjects(request): ClIP = request.META['REMOTE_ADDR'] #Check client access permission granted = False - if (settings.ALLOWED_ANALYS_IPS.has_key(ClIP)): granted = True + if (ClIP in settings.ALLOWED_ANALYS_IPS): granted = True if not granted: return HttpResponse("access denied.") outputfile = '' All=False - if (request.has_key('mode')): + if ('mode' in request): if request['mode']=='all': All=True diff --git a/htsworkflow/frontend/reports/reports.py b/htsworkflow/frontend/reports/reports.py index 18cd328..e2ff54f 100644 --- a/htsworkflow/frontend/reports/reports.py +++ b/htsworkflow/frontend/reports/reports.py @@ -27,7 +27,7 @@ def getBgColor(reads_cnt,exp_type): def report1(request): EXP = 'ChIP-seq' - if request.GET.has_key('aflid'): + if 'aflid' in request.GET: AFL_Id = request.GET['aflid'] try: AFL = Affiliation.objects.get(id=AFL_Id).name @@ -170,10 +170,10 @@ def report1(request): def report_RM(request): #for RNA-Seq and Methyl-Seq EXP = 'RNA-seq' - if request.GET.has_key('exp'): + if 'exp' in request.GET: EXP = request.GET['exp'] # Methyl-seq - if request.GET.has_key('aflid'): + if 'aflid' in request.GET: AFL_Id = request.GET['aflid'] try: AFL = Affiliation.objects.get(id=AFL_Id).name diff --git a/htsworkflow/pipelines/bustard.py b/htsworkflow/pipelines/bustard.py index 5df79c7..68ecc75 100644 --- a/htsworkflow/pipelines/bustard.py +++ b/htsworkflow/pipelines/bustard.py @@ -309,7 +309,7 @@ class Bustard(object): # add phasing parameters for lane in LANE_LIST: - if self.phasing.has_key(lane): + if lane in self.phasing: params.append(self.phasing[lane].get_elements()) # add crosstalk matrix if it exists diff --git a/htsworkflow/pipelines/ipar.py b/htsworkflow/pipelines/ipar.py index 52dda08..8719a06 100644 --- a/htsworkflow/pipelines/ipar.py +++ b/htsworkflow/pipelines/ipar.py @@ -210,7 +210,7 @@ def load_ipar_param_tree(paramfile): tree = ElementTree.parse(paramfile).getroot() run = tree.find('Run') - if run.attrib.has_key('Name') and run.attrib['Name'] in SOFTWARE_NAMES: + if run.attrib.get('Name', None) in SOFTWARE_NAMES: return run else: LOGGER.info("No run found") diff --git a/htsworkflow/pipelines/summary.py b/htsworkflow/pipelines/summary.py index 1da11a3..8f454e6 100644 --- a/htsworkflow/pipelines/summary.py +++ b/htsworkflow/pipelines/summary.py @@ -132,7 +132,7 @@ class SummaryGA(Summary): ('Lane Results Summary : Read 1', 0), ('Lane Results Summary : Read 2', 1),] for name, end in table_names: - if tables.has_key(name): + if name in tables: self._extract_lane_results_for_end(tables, name, end) if len(self.lane_results[0]) == 0: diff --git a/htsworkflow/util/fctracker.py b/htsworkflow/util/fctracker.py index 5ba3389..da90bbe 100644 --- a/htsworkflow/util/fctracker.py +++ b/htsworkflow/util/fctracker.py @@ -72,7 +72,7 @@ class fctracker: lane_library = [ (x[0][5], x[1]) for x in fc.items() if library_id_re.match(x[0]) ] for lane, library_id in lane_library: - if not self.library[library_id].has_key('lanes'): + if 'lanes' not in self.library[library_id]: self.library[library_id]['lanes'] = [] self.library[library_id]['lanes'].append((fc_id, lane)) diff --git a/scripts/htsw-update-archive b/scripts/htsw-update-archive index aeabc57..302fbfe 100755 --- a/scripts/htsw-update-archive +++ b/scripts/htsw-update-archive @@ -26,7 +26,7 @@ def build_flowcell_db(fcdb_filename, sequences, baseurl, apiid, apikey): flowcell_info = None # get info about flowcell from server or shelf - if not fcdb.has_key(flowcell): + if flowcell not in fcdb: url = api.flowcell_url(baseurl, flowcell) flowcell_info = api.retrieve_info(url, apidata) if flowcell_info is not None: -- 2.30.2