convert has_key to X in dictionary
authorDiane Trout <diane@ghic.org>
Thu, 29 Jan 2015 21:59:07 +0000 (13:59 -0800)
committerDiane Trout <diane@ghic.org>
Thu, 29 Jan 2015 21:59:07 +0000 (13:59 -0800)
experiments/experiments.py
htsworkflow/auth.py
htsworkflow/automation/spoolwatcher.py
htsworkflow/frontend/analysis/main.py
htsworkflow/frontend/reports/reports.py
htsworkflow/pipelines/bustard.py
htsworkflow/pipelines/ipar.py
htsworkflow/pipelines/summary.py
htsworkflow/util/fctracker.py
scripts/htsw-update-archive

index b8f905ecf3682d0e59e340b4597c12a17fdc084d..8738224d547ea47693902a2f48bf25c7affd526f 100644 (file)
@@ -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)
index 5688cc9c061231c560ade2fe0b694e238193dc82..1d781e19c3a44dda03bd9aacf4c5201a7010945e 100644 (file)
@@ -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
index e226234d6d392f67cd774cb436dc9660ad22e71b..2888be0beaac1d1e46ee0af34b8114ba2c4ecc76 100644 (file)
@@ -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)
index ba2a739d5be0b461aaf02264a40dda6ed90e6863..71d711d72dca7e9dac47806e9b3e4635d842d123 100644 (file)
@@ -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
 
index 18cd3285c5bb90b4fdeaea37292f02fdb9ade45a..e2ff54f817850babf06791e97ea26d0502af703d 100644 (file)
@@ -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
index 5df79c7fb80eb3afd5cba76f536e6c194a39d533..68ecc75c1fcbc9c6c969032cdef3995c1a99a3f0 100644 (file)
@@ -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
index 52dda0889c9b8cfc5aea23c6423e32beb2f9e1fa..8719a060cd9d1ef67a2abf0cc33e7055d4924e53 100644 (file)
@@ -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")
index 1da11a39b416f8141ca9f97c485d9477ed5dfbcb..8f454e6dbee1c8a804d7950c4c337a437dca3deb 100644 (file)
@@ -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:
index 5ba33892f741213bb1932292e5821551df379295..da90bbe68e12b9b11ce6cc10fbf7cd29755e2b6c 100644 (file)
@@ -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))
 
index aeabc57ff20189d716746de5f1afa7d8494f51eb..302fbfe45abcb3e979dc0ea52fb8bde4cfd64e39 100755 (executable)
@@ -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: